From 4d2a36f0fef72e07a3b8123394ee76ee4bb61291 Mon Sep 17 00:00:00 2001 From: Mamoon Raja Date: Thu, 29 Aug 2019 12:40:55 -0400 Subject: [PATCH 1/4] feat(regerate): regenerate services for pre-release --- .../Services/Assistant/V1/AssistantService.cs | 273 ++++++++-------- .../Services/Assistant/V2/AssistantService.cs | 44 ++- .../CompareComply/V1/CompareComplyService.cs | 78 ++--- .../Services/Discovery/V1/DiscoveryService.cs | 291 +++++++++++------- .../V3/LanguageTranslatorService.cs | 85 ++--- .../V1/NaturalLanguageClassifierService.cs | 69 +++-- .../V1/NaturalLanguageUnderstandingService.cs | 44 ++- .../V3/PersonalityInsightsService.cs | 73 +++-- .../SpeechToText/V1/SpeechToTextService.cs | 254 ++++++++------- .../TextToSpeech/V1/TextToSpeechService.cs | 90 +++--- .../ToneAnalyzer/V3/ToneAnalyzerService.cs | 57 ++-- .../V3/VisualRecognitionService.cs | 86 +++--- 12 files changed, 784 insertions(+), 660 deletions(-) diff --git a/Scripts/Services/Assistant/V1/AssistantService.cs b/Scripts/Services/Assistant/V1/AssistantService.cs index 95c961813..01cabb8aa 100644 --- a/Scripts/Services/Assistant/V1/AssistantService.cs +++ b/Scripts/Services/Assistant/V1/AssistantService.cs @@ -18,6 +18,7 @@ using System.Collections.Generic; using System.Text; using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; using IBM.Cloud.SDK.Connection; using IBM.Cloud.SDK.Utilities; using IBM.Watson.Assistant.V1.Model; @@ -33,20 +34,16 @@ public partial class AssistantService : BaseService private const string serviceId = "assistant"; private const string defaultUrl = "https://gateway.watsonplatform.net/assistant/api"; - #region Credentials + #region Authenticator /// - /// Gets and sets the credentials of the service. Replace the default endpoint if endpoint is defined. + /// Gets and sets the authenticator of the service. Replace the default endpoint if endpoint is defined. /// - public Credentials Credentials + public Authenticator Authenticator { - get { return credentials; } + get { return authenticator; } set { - credentials = value; - if (!string.IsNullOrEmpty(credentials.Url)) - { - Url = credentials.Url; - } + authenticator = value; } } #endregion @@ -90,17 +87,14 @@ public bool DisableSslVerification /// AssistantService constructor. /// /// The service version date in `yyyy-mm-dd` format. - public AssistantService(string versionDate) : base(versionDate, serviceId) - { - VersionDate = versionDate; - } + public AssistantService(string versionDate) : this(versionDate, ConfigBasedAuthenticatorFactory.GetAuthenticator(serviceId)) {} /// /// AssistantService constructor. /// /// The service version date in `yyyy-mm-dd` format. - /// The service credentials. - public AssistantService(string versionDate, Credentials credentials) : base(versionDate, credentials, serviceId) + /// The service authenticator. + public AssistantService(string versionDate, Authenticator authenticator) : base(versionDate, authenticator, serviceId) { if (string.IsNullOrEmpty(versionDate)) { @@ -111,18 +105,19 @@ public AssistantService(string versionDate, Credentials credentials) : base(vers VersionDate = versionDate; } - if (credentials.HasCredentials() || credentials.HasTokenData()) + if (authenticator != null) { - Credentials = credentials; + Authenticator = authenticator; - if (string.IsNullOrEmpty(credentials.Url)) + if (string.IsNullOrEmpty(Url)) { - credentials.Url = defaultUrl; + Authenticator.Url = defaultUrl; } + Authenticator.Url = Url; } else { - 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"); + 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"); } } @@ -131,6 +126,11 @@ public AssistantService(string versionDate, Credentials credentials) : base(vers /// /// Send user input to a workspace and receive a response. /// + /// **Note:** For most applications, there are significant advantages to using the v2 runtime API instead. These + /// advantages include ease of deployment, automatic state management, versioning, and search capabilities. For + /// more information, see the + /// [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-api-overview). + /// /// There is no rate limit for this operation. /// /// The callback function that is invoked when the operation completes. @@ -151,7 +151,7 @@ public AssistantService(string versionDate, Credentials credentials) : base(vers /// Whether to include additional diagnostic information about the dialog /// nodes that were visited during processing of the message. (optional, default to false) /// MessageResponse - public bool Message(Callback callback, string workspaceId, JObject input = null, List intents = null, List entities = null, bool? alternateIntents = null, JObject context = null, JObject output = null, bool? nodesVisitedDetails = null) + public bool Message(Callback callback, string workspaceId, JObject input = null, List intents = null, List entities = null, bool? alternateIntents = null, JObject context = null, JObject output = null, bool? nodesVisitedDetails = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `Message`"); @@ -202,11 +202,12 @@ public bool Message(Callback callback, string workspaceId, JObj req.OnResponse = OnMessageResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/message", workspaceId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/message", workspaceId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -244,15 +245,13 @@ private void OnMessageResponse(RESTConnector.Request req, RESTConnector.Response /// /// The callback function that is invoked when the operation completes. /// The number of records to return in each page of results. (optional) - /// Whether to include information about the number of records returned. (optional, - /// default to false) /// The attribute by which returned workspaces will be sorted. To reverse the sort order, /// prefix the value with a minus sign (`-`). (optional) /// A token identifying the page of results to retrieve. (optional) /// Whether to include the audit properties (`created` and `updated` timestamps) in /// the response. (optional, default to false) /// WorkspaceCollection - public bool ListWorkspaces(Callback callback, long? pageLimit = null, bool? includeCount = null, string sort = null, string cursor = null, bool? includeAudit = null) + public bool ListWorkspaces(Callback callback, long? pageLimit = null, string sort = null, string cursor = null, bool? includeAudit = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `ListWorkspaces`"); @@ -281,10 +280,6 @@ public bool ListWorkspaces(Callback callback, long? pageLim { req.Parameters["page_limit"] = pageLimit; } - if (includeCount != null) - { - req.Parameters["include_count"] = (bool)includeCount ? "true" : "false"; - } if (!string.IsNullOrEmpty(sort)) { req.Parameters["sort"] = sort; @@ -300,11 +295,12 @@ public bool ListWorkspaces(Callback callback, long? pageLim req.OnResponse = OnListWorkspacesResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/workspaces"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/workspaces"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -412,11 +408,12 @@ public bool CreateWorkspace(Callback callback, string name = null, st req.OnResponse = OnCreateWorkspaceResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/workspaces"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/workspaces"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -506,11 +503,12 @@ public bool GetWorkspace(Callback callback, string workspaceId, bool? req.OnResponse = OnGetWorkspaceResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}", workspaceId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}", workspaceId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -632,11 +630,12 @@ public bool UpdateWorkspace(Callback callback, string workspaceId, st req.OnResponse = OnUpdateWorkspaceResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}", workspaceId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}", workspaceId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -705,11 +704,12 @@ public bool DeleteWorkspace(Callback callback, string workspaceId) req.OnResponse = OnDeleteWorkspaceResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}", workspaceId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}", workspaceId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -752,15 +752,13 @@ private void OnDeleteWorkspaceResponse(RESTConnector.Request req, RESTConnector. /// returned data includes only information about the element itself. If **export**=`true`, all content, /// including subelements, is included. (optional, default to false) /// The number of records to return in each page of results. (optional) - /// Whether to include information about the number of records returned. (optional, - /// default to false) /// The attribute by which returned intents will be sorted. To reverse the sort order, prefix /// the value with a minus sign (`-`). (optional) /// A token identifying the page of results to retrieve. (optional) /// Whether to include the audit properties (`created` and `updated` timestamps) in /// the response. (optional, default to false) /// IntentCollection - public bool ListIntents(Callback callback, string workspaceId, bool? export = null, long? pageLimit = null, bool? includeCount = null, string sort = null, string cursor = null, bool? includeAudit = null) + public bool ListIntents(Callback callback, string workspaceId, bool? export = null, long? pageLimit = null, string sort = null, string cursor = null, bool? includeAudit = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `ListIntents`"); @@ -795,10 +793,6 @@ public bool ListIntents(Callback callback, string workspaceId, { req.Parameters["page_limit"] = pageLimit; } - if (includeCount != null) - { - req.Parameters["include_count"] = (bool)includeCount ? "true" : "false"; - } if (!string.IsNullOrEmpty(sort)) { req.Parameters["sort"] = sort; @@ -814,11 +808,12 @@ public bool ListIntents(Callback callback, string workspaceId, req.OnResponse = OnListIntentsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/intents", workspaceId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/intents", workspaceId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -909,11 +904,12 @@ public bool CreateIntent(Callback callback, string workspaceId, string i req.OnResponse = OnCreateIntentResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/intents", workspaceId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/intents", workspaceId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -999,11 +995,12 @@ public bool GetIntent(Callback callback, string workspaceId, string inte req.OnResponse = OnGetIntentResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/intents/{1}", workspaceId, intent)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/intents/{1}", workspaceId, intent)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1096,11 +1093,12 @@ public bool UpdateIntent(Callback callback, string workspaceId, string i req.OnResponse = OnUpdateIntentResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/intents/{1}", workspaceId, intent)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/intents/{1}", workspaceId, intent)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1172,11 +1170,12 @@ public bool DeleteIntent(Callback callback, string workspaceId, string i req.OnResponse = OnDeleteIntentResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/intents/{1}", workspaceId, intent)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/intents/{1}", workspaceId, intent)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1216,15 +1215,13 @@ private void OnDeleteIntentResponse(RESTConnector.Request req, RESTConnector.Res /// Unique identifier of the workspace. /// The intent name. /// The number of records to return in each page of results. (optional) - /// Whether to include information about the number of records returned. (optional, - /// default to false) /// The attribute by which returned examples will be sorted. To reverse the sort order, /// prefix the value with a minus sign (`-`). (optional) /// A token identifying the page of results to retrieve. (optional) /// Whether to include the audit properties (`created` and `updated` timestamps) in /// the response. (optional, default to false) /// ExampleCollection - public bool ListExamples(Callback callback, string workspaceId, string intent, long? pageLimit = null, bool? includeCount = null, string sort = null, string cursor = null, bool? includeAudit = null) + public bool ListExamples(Callback callback, string workspaceId, string intent, long? pageLimit = null, string sort = null, string cursor = null, bool? includeAudit = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `ListExamples`"); @@ -1257,10 +1254,6 @@ public bool ListExamples(Callback callback, string workspaceI { req.Parameters["page_limit"] = pageLimit; } - if (includeCount != null) - { - req.Parameters["include_count"] = (bool)includeCount ? "true" : "false"; - } if (!string.IsNullOrEmpty(sort)) { req.Parameters["sort"] = sort; @@ -1276,11 +1269,12 @@ public bool ListExamples(Callback callback, string workspaceI req.OnResponse = OnListExamplesResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/intents/{1}/examples", workspaceId, intent)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/intents/{1}/examples", workspaceId, intent)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1370,11 +1364,12 @@ public bool CreateExample(Callback callback, string workspaceId, string req.OnResponse = OnCreateExampleResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/intents/{1}/examples", workspaceId, intent)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/intents/{1}/examples", workspaceId, intent)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1455,11 +1450,12 @@ public bool GetExample(Callback callback, string workspaceId, string in req.OnResponse = OnGetExampleResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/intents/{1}/examples/{2}", workspaceId, intent, text)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/intents/{1}/examples/{2}", workspaceId, intent, text)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1551,11 +1547,12 @@ public bool UpdateExample(Callback callback, string workspaceId, string req.OnResponse = OnUpdateExampleResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/intents/{1}/examples/{2}", workspaceId, intent, text)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/intents/{1}/examples/{2}", workspaceId, intent, text)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1630,11 +1627,12 @@ public bool DeleteExample(Callback callback, string workspaceId, string req.OnResponse = OnDeleteExampleResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/intents/{1}/examples/{2}", workspaceId, intent, text)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/intents/{1}/examples/{2}", workspaceId, intent, text)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1674,15 +1672,13 @@ private void OnDeleteExampleResponse(RESTConnector.Request req, RESTConnector.Re /// The callback function that is invoked when the operation completes. /// Unique identifier of the workspace. /// The number of records to return in each page of results. (optional) - /// Whether to include information about the number of records returned. (optional, - /// default to false) /// The attribute by which returned counterexamples will be sorted. To reverse the sort /// order, prefix the value with a minus sign (`-`). (optional) /// A token identifying the page of results to retrieve. (optional) /// Whether to include the audit properties (`created` and `updated` timestamps) in /// the response. (optional, default to false) /// CounterexampleCollection - public bool ListCounterexamples(Callback callback, string workspaceId, long? pageLimit = null, bool? includeCount = null, string sort = null, string cursor = null, bool? includeAudit = null) + public bool ListCounterexamples(Callback callback, string workspaceId, long? pageLimit = null, string sort = null, string cursor = null, bool? includeAudit = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `ListCounterexamples`"); @@ -1713,10 +1709,6 @@ public bool ListCounterexamples(Callback callback, str { req.Parameters["page_limit"] = pageLimit; } - if (includeCount != null) - { - req.Parameters["include_count"] = (bool)includeCount ? "true" : "false"; - } if (!string.IsNullOrEmpty(sort)) { req.Parameters["sort"] = sort; @@ -1732,11 +1724,12 @@ public bool ListCounterexamples(Callback callback, str req.OnResponse = OnListCounterexamplesResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/counterexamples", workspaceId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/counterexamples", workspaceId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1822,11 +1815,12 @@ public bool CreateCounterexample(Callback callback, string works req.OnResponse = OnCreateCounterexampleResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/counterexamples", workspaceId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/counterexamples", workspaceId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1905,11 +1899,12 @@ public bool GetCounterexample(Callback callback, string workspac req.OnResponse = OnGetCounterexampleResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/counterexamples/{1}", workspaceId, text)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/counterexamples/{1}", workspaceId, text)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1995,11 +1990,12 @@ public bool UpdateCounterexample(Callback callback, string works req.OnResponse = OnUpdateCounterexampleResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/counterexamples/{1}", workspaceId, text)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/counterexamples/{1}", workspaceId, text)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -2072,11 +2068,12 @@ public bool DeleteCounterexample(Callback callback, string workspaceId, req.OnResponse = OnDeleteCounterexampleResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/counterexamples/{1}", workspaceId, text)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/counterexamples/{1}", workspaceId, text)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -2119,15 +2116,13 @@ private void OnDeleteCounterexampleResponse(RESTConnector.Request req, RESTConne /// returned data includes only information about the element itself. If **export**=`true`, all content, /// including subelements, is included. (optional, default to false) /// The number of records to return in each page of results. (optional) - /// Whether to include information about the number of records returned. (optional, - /// default to false) /// The attribute by which returned entities will be sorted. To reverse the sort order, /// prefix the value with a minus sign (`-`). (optional) /// A token identifying the page of results to retrieve. (optional) /// Whether to include the audit properties (`created` and `updated` timestamps) in /// the response. (optional, default to false) /// EntityCollection - public bool ListEntities(Callback callback, string workspaceId, bool? export = null, long? pageLimit = null, bool? includeCount = null, string sort = null, string cursor = null, bool? includeAudit = null) + public bool ListEntities(Callback callback, string workspaceId, bool? export = null, long? pageLimit = null, string sort = null, string cursor = null, bool? includeAudit = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `ListEntities`"); @@ -2162,10 +2157,6 @@ public bool ListEntities(Callback callback, string workspaceId { req.Parameters["page_limit"] = pageLimit; } - if (includeCount != null) - { - req.Parameters["include_count"] = (bool)includeCount ? "true" : "false"; - } if (!string.IsNullOrEmpty(sort)) { req.Parameters["sort"] = sort; @@ -2181,11 +2172,12 @@ public bool ListEntities(Callback callback, string workspaceId req.OnResponse = OnListEntitiesResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/entities", workspaceId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/entities", workspaceId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -2283,11 +2275,12 @@ public bool CreateEntity(Callback callback, string workspaceId, string e req.OnResponse = OnCreateEntityResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/entities", workspaceId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/entities", workspaceId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -2373,11 +2366,12 @@ public bool GetEntity(Callback callback, string workspaceId, string enti req.OnResponse = OnGetEntityResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/entities/{1}", workspaceId, entity)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/entities/{1}", workspaceId, entity)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -2476,11 +2470,12 @@ public bool UpdateEntity(Callback callback, string workspaceId, string e req.OnResponse = OnUpdateEntityResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/entities/{1}", workspaceId, entity)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/entities/{1}", workspaceId, entity)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -2552,11 +2547,12 @@ public bool DeleteEntity(Callback callback, string workspaceId, string e req.OnResponse = OnDeleteEntityResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/entities/{1}", workspaceId, entity)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/entities/{1}", workspaceId, entity)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -2642,11 +2638,12 @@ public bool ListMentions(Callback callback, string work req.OnResponse = OnListMentionsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/entities/{1}/mentions", workspaceId, entity)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/entities/{1}/mentions", workspaceId, entity)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -2689,15 +2686,13 @@ private void OnListMentionsResponse(RESTConnector.Request req, RESTConnector.Res /// returned data includes only information about the element itself. If **export**=`true`, all content, /// including subelements, is included. (optional, default to false) /// The number of records to return in each page of results. (optional) - /// Whether to include information about the number of records returned. (optional, - /// default to false) /// The attribute by which returned entity values will be sorted. To reverse the sort order, /// prefix the value with a minus sign (`-`). (optional) /// A token identifying the page of results to retrieve. (optional) /// Whether to include the audit properties (`created` and `updated` timestamps) in /// the response. (optional, default to false) /// ValueCollection - public bool ListValues(Callback callback, string workspaceId, string entity, bool? export = null, long? pageLimit = null, bool? includeCount = null, string sort = null, string cursor = null, bool? includeAudit = null) + public bool ListValues(Callback callback, string workspaceId, string entity, bool? export = null, long? pageLimit = null, string sort = null, string cursor = null, bool? includeAudit = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `ListValues`"); @@ -2734,10 +2729,6 @@ public bool ListValues(Callback callback, string workspaceId, s { req.Parameters["page_limit"] = pageLimit; } - if (includeCount != null) - { - req.Parameters["include_count"] = (bool)includeCount ? "true" : "false"; - } if (!string.IsNullOrEmpty(sort)) { req.Parameters["sort"] = sort; @@ -2753,11 +2744,12 @@ public bool ListValues(Callback callback, string workspaceId, s req.OnResponse = OnListValuesResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/entities/{1}/values", workspaceId, entity)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/entities/{1}/values", workspaceId, entity)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -2803,7 +2795,7 @@ private void OnListValuesResponse(RESTConnector.Request req, RESTConnector.Respo /// - It cannot contain carriage return, newline, or tab characters. /// - It cannot consist of only whitespace characters. /// Any metadata related to the entity value. (optional) - /// Specifies the type of entity value. (optional, default to synonyms) + /// Specifies the type of entity value. (optional, default to synonyms) /// An array of synonyms for the entity value. A value can specify either synonyms or /// patterns (depending on the value type), but not both. A synonym must conform to the following resrictions: /// - It cannot contain carriage return, newline, or tab characters. @@ -2814,7 +2806,7 @@ private void OnListValuesResponse(RESTConnector.Request req, RESTConnector.Respo /// [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-entities#entities-create-dictionary-based). /// (optional) /// Value - public bool CreateValue(Callback callback, string workspaceId, string entity, string value, Dictionary metadata = null, string valueType = null, List synonyms = null, List patterns = null) + public bool CreateValue(Callback callback, string workspaceId, string entity, string value, Dictionary metadata = null, string type = null, List synonyms = null, List patterns = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `CreateValue`"); @@ -2853,8 +2845,8 @@ public bool CreateValue(Callback callback, string workspaceId, string ent bodyObject["value"] = value; if (metadata != null) bodyObject["metadata"] = JToken.FromObject(metadata); - if (!string.IsNullOrEmpty(valueType)) - bodyObject["type"] = valueType; + if (!string.IsNullOrEmpty(type)) + bodyObject["type"] = type; if (synonyms != null && synonyms.Count > 0) bodyObject["synonyms"] = JToken.FromObject(synonyms); if (patterns != null && patterns.Count > 0) @@ -2863,11 +2855,12 @@ public bool CreateValue(Callback callback, string workspaceId, string ent req.OnResponse = OnCreateValueResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/entities/{1}/values", workspaceId, entity)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/entities/{1}/values", workspaceId, entity)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -2955,11 +2948,12 @@ public bool GetValue(Callback callback, string workspaceId, string entity req.OnResponse = OnGetValueResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/entities/{1}/values/{2}", workspaceId, entity, value)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/entities/{1}/values/{2}", workspaceId, entity, value)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -3007,7 +3001,7 @@ private void OnGetValueResponse(RESTConnector.Request req, RESTConnector.Respons /// - It cannot contain carriage return, newline, or tab characters. /// - It cannot consist of only whitespace characters. (optional) /// Any metadata related to the entity value. (optional) - /// Specifies the type of entity value. (optional, default to synonyms) + /// Specifies the type of entity value. (optional, default to synonyms) /// An array of synonyms for the entity value. A value can specify either synonyms or /// patterns (depending on the value type), but not both. A synonym must conform to the following resrictions: /// - It cannot contain carriage return, newline, or tab characters. @@ -3018,7 +3012,7 @@ private void OnGetValueResponse(RESTConnector.Request req, RESTConnector.Respons /// [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-entities#entities-create-dictionary-based). /// (optional) /// Value - public bool UpdateValue(Callback callback, string workspaceId, string entity, string value, string newValue = null, Dictionary newMetadata = null, string newValueType = null, List newSynonyms = null, List newPatterns = null) + public bool UpdateValue(Callback callback, string workspaceId, string entity, string value, string newValue = null, Dictionary newMetadata = null, string newType = null, List newSynonyms = null, List newPatterns = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `UpdateValue`"); @@ -3057,8 +3051,8 @@ public bool UpdateValue(Callback callback, string workspaceId, string ent bodyObject["value"] = newValue; if (newMetadata != null) bodyObject["metadata"] = JToken.FromObject(newMetadata); - if (!string.IsNullOrEmpty(newValueType)) - bodyObject["type"] = newValueType; + if (!string.IsNullOrEmpty(newType)) + bodyObject["type"] = newType; if (newSynonyms != null && newSynonyms.Count > 0) bodyObject["synonyms"] = JToken.FromObject(newSynonyms); if (newPatterns != null && newPatterns.Count > 0) @@ -3067,11 +3061,12 @@ public bool UpdateValue(Callback callback, string workspaceId, string ent req.OnResponse = OnUpdateValueResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/entities/{1}/values/{2}", workspaceId, entity, value)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/entities/{1}/values/{2}", workspaceId, entity, value)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -3146,11 +3141,12 @@ public bool DeleteValue(Callback callback, string workspaceId, string en req.OnResponse = OnDeleteValueResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/entities/{1}/values/{2}", workspaceId, entity, value)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/entities/{1}/values/{2}", workspaceId, entity, value)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -3191,15 +3187,13 @@ private void OnDeleteValueResponse(RESTConnector.Request req, RESTConnector.Resp /// The name of the entity. /// The text of the entity value. /// The number of records to return in each page of results. (optional) - /// Whether to include information about the number of records returned. (optional, - /// default to false) /// The attribute by which returned entity value synonyms will be sorted. To reverse the sort /// order, prefix the value with a minus sign (`-`). (optional) /// A token identifying the page of results to retrieve. (optional) /// Whether to include the audit properties (`created` and `updated` timestamps) in /// the response. (optional, default to false) /// SynonymCollection - public bool ListSynonyms(Callback callback, string workspaceId, string entity, string value, long? pageLimit = null, bool? includeCount = null, string sort = null, string cursor = null, bool? includeAudit = null) + public bool ListSynonyms(Callback callback, string workspaceId, string entity, string value, long? pageLimit = null, string sort = null, string cursor = null, bool? includeAudit = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `ListSynonyms`"); @@ -3234,10 +3228,6 @@ public bool ListSynonyms(Callback callback, string workspaceI { req.Parameters["page_limit"] = pageLimit; } - if (includeCount != null) - { - req.Parameters["include_count"] = (bool)includeCount ? "true" : "false"; - } if (!string.IsNullOrEmpty(sort)) { req.Parameters["sort"] = sort; @@ -3253,11 +3243,12 @@ public bool ListSynonyms(Callback callback, string workspaceI req.OnResponse = OnListSynonymsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/entities/{1}/values/{2}/synonyms", workspaceId, entity, value)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/entities/{1}/values/{2}/synonyms", workspaceId, entity, value)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -3347,11 +3338,12 @@ public bool CreateSynonym(Callback callback, string workspaceId, string req.OnResponse = OnCreateSynonymResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/entities/{1}/values/{2}/synonyms", workspaceId, entity, value)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/entities/{1}/values/{2}/synonyms", workspaceId, entity, value)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -3435,11 +3427,12 @@ public bool GetSynonym(Callback callback, string workspaceId, string en req.OnResponse = OnGetSynonymResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/entities/{1}/values/{2}/synonyms/{3}", workspaceId, entity, value, synonym)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/entities/{1}/values/{2}/synonyms/{3}", workspaceId, entity, value, synonym)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -3530,11 +3523,12 @@ public bool UpdateSynonym(Callback callback, string workspaceId, string req.OnResponse = OnUpdateSynonymResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/entities/{1}/values/{2}/synonyms/{3}", workspaceId, entity, value, synonym)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/entities/{1}/values/{2}/synonyms/{3}", workspaceId, entity, value, synonym)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -3612,11 +3606,12 @@ public bool DeleteSynonym(Callback callback, string workspaceId, string req.OnResponse = OnDeleteSynonymResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/entities/{1}/values/{2}/synonyms/{3}", workspaceId, entity, value, synonym)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/entities/{1}/values/{2}/synonyms/{3}", workspaceId, entity, value, synonym)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -3655,15 +3650,13 @@ private void OnDeleteSynonymResponse(RESTConnector.Request req, RESTConnector.Re /// The callback function that is invoked when the operation completes. /// Unique identifier of the workspace. /// The number of records to return in each page of results. (optional) - /// Whether to include information about the number of records returned. (optional, - /// default to false) /// The attribute by which returned dialog nodes will be sorted. To reverse the sort order, /// prefix the value with a minus sign (`-`). (optional) /// A token identifying the page of results to retrieve. (optional) /// Whether to include the audit properties (`created` and `updated` timestamps) in /// the response. (optional, default to false) /// DialogNodeCollection - public bool ListDialogNodes(Callback callback, string workspaceId, long? pageLimit = null, bool? includeCount = null, string sort = null, string cursor = null, bool? includeAudit = null) + public bool ListDialogNodes(Callback callback, string workspaceId, long? pageLimit = null, string sort = null, string cursor = null, bool? includeAudit = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `ListDialogNodes`"); @@ -3694,10 +3687,6 @@ public bool ListDialogNodes(Callback callback, string work { req.Parameters["page_limit"] = pageLimit; } - if (includeCount != null) - { - req.Parameters["include_count"] = (bool)includeCount ? "true" : "false"; - } if (!string.IsNullOrEmpty(sort)) { req.Parameters["sort"] = sort; @@ -3713,11 +3702,12 @@ public bool ListDialogNodes(Callback callback, string work req.OnResponse = OnListDialogNodesResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/dialog_nodes", workspaceId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/dialog_nodes", workspaceId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -3779,7 +3769,7 @@ private void OnListDialogNodesResponse(RESTConnector.Request req, RESTConnector. /// restrictions: /// - It can contain only Unicode alphanumeric, space, underscore, hyphen, and dot characters. /// (optional) - /// How the dialog node is processed. (optional) + /// How the dialog node is processed. (optional) /// How an `event_handler` node is processed. (optional) /// The location in the dialog context where output is stored. (optional) /// An array of objects describing any actions to be invoked by the dialog node. @@ -3791,7 +3781,7 @@ private void OnListDialogNodesResponse(RESTConnector.Request req, RESTConnector. /// A label that can be displayed externally to describe the purpose of the node to /// users. (optional) /// DialogNode - public bool CreateDialogNode(Callback callback, string workspaceId, string dialogNode, string description = null, string conditions = null, string parent = null, string previousSibling = null, JObject output = null, Dictionary context = null, Dictionary metadata = null, DialogNodeNextStep nextStep = null, string title = null, string nodeType = null, string eventName = null, string variable = null, List actions = null, string digressIn = null, string digressOut = null, string digressOutSlots = null, string userLabel = null) + public bool CreateDialogNode(Callback callback, string workspaceId, string dialogNode, string description = null, string conditions = null, string parent = null, string previousSibling = null, JObject output = null, Dictionary context = null, Dictionary metadata = null, DialogNodeNextStep nextStep = null, string title = null, string type = null, string eventName = null, string variable = null, List actions = null, string digressIn = null, string digressOut = null, string digressOutSlots = null, string userLabel = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `CreateDialogNode`"); @@ -3844,8 +3834,8 @@ public bool CreateDialogNode(Callback callback, string workspaceId, bodyObject["next_step"] = JToken.FromObject(nextStep); if (!string.IsNullOrEmpty(title)) bodyObject["title"] = title; - if (!string.IsNullOrEmpty(nodeType)) - bodyObject["type"] = nodeType; + if (!string.IsNullOrEmpty(type)) + bodyObject["type"] = type; if (!string.IsNullOrEmpty(eventName)) bodyObject["event_name"] = eventName; if (!string.IsNullOrEmpty(variable)) @@ -3864,11 +3854,12 @@ public bool CreateDialogNode(Callback callback, string workspaceId, req.OnResponse = OnCreateDialogNodeResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/dialog_nodes", workspaceId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/dialog_nodes", workspaceId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -3946,11 +3937,12 @@ public bool GetDialogNode(Callback callback, string workspaceId, str req.OnResponse = OnGetDialogNodeResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/dialog_nodes/{1}", workspaceId, dialogNode)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/dialog_nodes/{1}", workspaceId, dialogNode)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -4014,7 +4006,7 @@ private void OnGetDialogNodeResponse(RESTConnector.Request req, RESTConnector.Re /// restrictions: /// - It can contain only Unicode alphanumeric, space, underscore, hyphen, and dot characters. /// (optional) - /// How the dialog node is processed. (optional) + /// How the dialog node is processed. (optional) /// How an `event_handler` node is processed. (optional) /// The location in the dialog context where output is stored. (optional) /// An array of objects describing any actions to be invoked by the dialog node. @@ -4027,7 +4019,7 @@ private void OnGetDialogNodeResponse(RESTConnector.Request req, RESTConnector.Re /// A label that can be displayed externally to describe the purpose of the node to /// users. (optional) /// DialogNode - public bool UpdateDialogNode(Callback callback, string workspaceId, string dialogNode, string newDialogNode = null, string newDescription = null, string newConditions = null, string newParent = null, string newPreviousSibling = null, JObject newOutput = null, Dictionary newContext = null, Dictionary newMetadata = null, DialogNodeNextStep newNextStep = null, string newTitle = null, string newNodeType = null, string newEventName = null, string newVariable = null, List newActions = null, string newDigressIn = null, string newDigressOut = null, string newDigressOutSlots = null, string newUserLabel = null) + public bool UpdateDialogNode(Callback callback, string workspaceId, string dialogNode, string newDialogNode = null, string newDescription = null, string newConditions = null, string newParent = null, string newPreviousSibling = null, JObject newOutput = null, Dictionary newContext = null, Dictionary newMetadata = null, DialogNodeNextStep newNextStep = null, string newTitle = null, string newType = null, string newEventName = null, string newVariable = null, List newActions = null, string newDigressIn = null, string newDigressOut = null, string newDigressOutSlots = null, string newUserLabel = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `UpdateDialogNode`"); @@ -4080,8 +4072,8 @@ public bool UpdateDialogNode(Callback callback, string workspaceId, bodyObject["next_step"] = JToken.FromObject(newNextStep); if (!string.IsNullOrEmpty(newTitle)) bodyObject["title"] = newTitle; - if (!string.IsNullOrEmpty(newNodeType)) - bodyObject["type"] = newNodeType; + if (!string.IsNullOrEmpty(newType)) + bodyObject["type"] = newType; if (!string.IsNullOrEmpty(newEventName)) bodyObject["event_name"] = newEventName; if (!string.IsNullOrEmpty(newVariable)) @@ -4100,11 +4092,12 @@ public bool UpdateDialogNode(Callback callback, string workspaceId, req.OnResponse = OnUpdateDialogNodeResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/dialog_nodes/{1}", workspaceId, dialogNode)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/dialog_nodes/{1}", workspaceId, dialogNode)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -4176,11 +4169,12 @@ public bool DeleteDialogNode(Callback callback, string workspaceId, stri req.OnResponse = OnDeleteDialogNodeResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/dialog_nodes/{1}", workspaceId, dialogNode)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/dialog_nodes/{1}", workspaceId, dialogNode)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -4275,11 +4269,12 @@ public bool ListLogs(Callback callback, string workspaceId, strin req.OnResponse = OnListLogsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/workspaces/{0}/logs", workspaceId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/workspaces/{0}/logs", workspaceId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -4373,11 +4368,12 @@ public bool ListAllLogs(Callback callback, string filter, string req.OnResponse = OnListAllLogsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/logs"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/logs"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -4453,11 +4449,12 @@ public bool DeleteUserData(Callback callback, string customerId) req.OnResponse = OnDeleteUserDataResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/user_data"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/user_data"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } diff --git a/Scripts/Services/Assistant/V2/AssistantService.cs b/Scripts/Services/Assistant/V2/AssistantService.cs index ffc755fff..03eff5dec 100644 --- a/Scripts/Services/Assistant/V2/AssistantService.cs +++ b/Scripts/Services/Assistant/V2/AssistantService.cs @@ -18,6 +18,7 @@ using System.Collections.Generic; using System.Text; using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; using IBM.Cloud.SDK.Connection; using IBM.Cloud.SDK.Utilities; using IBM.Watson.Assistant.V2.Model; @@ -33,20 +34,16 @@ public partial class AssistantService : BaseService private const string serviceId = "assistant"; private const string defaultUrl = "https://gateway.watsonplatform.net/assistant/api"; - #region Credentials + #region Authenticator /// - /// Gets and sets the credentials of the service. Replace the default endpoint if endpoint is defined. + /// Gets and sets the authenticator of the service. Replace the default endpoint if endpoint is defined. /// - public Credentials Credentials + public Authenticator Authenticator { - get { return credentials; } + get { return authenticator; } set { - credentials = value; - if (!string.IsNullOrEmpty(credentials.Url)) - { - Url = credentials.Url; - } + authenticator = value; } } #endregion @@ -90,17 +87,14 @@ public bool DisableSslVerification /// AssistantService constructor. /// /// The service version date in `yyyy-mm-dd` format. - public AssistantService(string versionDate) : base(versionDate, serviceId) - { - VersionDate = versionDate; - } + public AssistantService(string versionDate) : this(versionDate, ConfigBasedAuthenticatorFactory.GetAuthenticator(serviceId)) {} /// /// AssistantService constructor. /// /// The service version date in `yyyy-mm-dd` format. - /// The service credentials. - public AssistantService(string versionDate, Credentials credentials) : base(versionDate, credentials, serviceId) + /// The service authenticator. + public AssistantService(string versionDate, Authenticator authenticator) : base(versionDate, authenticator, serviceId) { if (string.IsNullOrEmpty(versionDate)) { @@ -111,18 +105,19 @@ public AssistantService(string versionDate, Credentials credentials) : base(vers VersionDate = versionDate; } - if (credentials.HasCredentials() || credentials.HasTokenData()) + if (authenticator != null) { - Credentials = credentials; + Authenticator = authenticator; - if (string.IsNullOrEmpty(credentials.Url)) + if (string.IsNullOrEmpty(Url)) { - credentials.Url = defaultUrl; + Authenticator.Url = defaultUrl; } + Authenticator.Url = Url; } else { - 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"); + 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"); } } @@ -170,11 +165,12 @@ public bool CreateSession(Callback callback, string assistantId req.OnResponse = OnCreateSessionResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v2/assistants/{0}/sessions", assistantId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v2/assistants/{0}/sessions", assistantId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -249,11 +245,12 @@ public bool DeleteSession(Callback callback, string assistantId, string req.OnResponse = OnDeleteSessionResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v2/assistants/{0}/sessions/{1}", assistantId, sessionId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v2/assistants/{0}/sessions/{1}", assistantId, sessionId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -343,11 +340,12 @@ public bool Message(Callback callback, string assistantId, stri req.OnResponse = OnMessageResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v2/assistants/{0}/sessions/{1}/message", assistantId, sessionId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v2/assistants/{0}/sessions/{1}/message", assistantId, sessionId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } diff --git a/Scripts/Services/CompareComply/V1/CompareComplyService.cs b/Scripts/Services/CompareComply/V1/CompareComplyService.cs index a0cdeb9f2..7a51316c6 100644 --- a/Scripts/Services/CompareComply/V1/CompareComplyService.cs +++ b/Scripts/Services/CompareComply/V1/CompareComplyService.cs @@ -18,6 +18,7 @@ using System.Collections.Generic; using System.Text; using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; using IBM.Cloud.SDK.Connection; using IBM.Cloud.SDK.Utilities; using IBM.Watson.CompareComply.V1.Model; @@ -33,20 +34,16 @@ public partial class CompareComplyService : BaseService private const string serviceId = "compare_comply"; private const string defaultUrl = "https://gateway.watsonplatform.net/compare-comply/api"; - #region Credentials + #region Authenticator /// - /// Gets and sets the credentials of the service. Replace the default endpoint if endpoint is defined. + /// Gets and sets the authenticator of the service. Replace the default endpoint if endpoint is defined. /// - public Credentials Credentials + public Authenticator Authenticator { - get { return credentials; } + get { return authenticator; } set { - credentials = value; - if (!string.IsNullOrEmpty(credentials.Url)) - { - Url = credentials.Url; - } + authenticator = value; } } #endregion @@ -90,17 +87,14 @@ public bool DisableSslVerification /// CompareComplyService constructor. /// /// The service version date in `yyyy-mm-dd` format. - public CompareComplyService(string versionDate) : base(versionDate, serviceId) - { - VersionDate = versionDate; - } + public CompareComplyService(string versionDate) : this(versionDate, ConfigBasedAuthenticatorFactory.GetAuthenticator(serviceId)) {} /// /// CompareComplyService constructor. /// /// The service version date in `yyyy-mm-dd` format. - /// The service credentials. - public CompareComplyService(string versionDate, Credentials credentials) : base(versionDate, credentials, serviceId) + /// The service authenticator. + public CompareComplyService(string versionDate, Authenticator authenticator) : base(versionDate, authenticator, serviceId) { if (string.IsNullOrEmpty(versionDate)) { @@ -111,18 +105,19 @@ public CompareComplyService(string versionDate, Credentials credentials) : base( VersionDate = versionDate; } - if (credentials.HasCredentials() || credentials.HasTokenData()) + if (authenticator != null) { - Credentials = credentials; + Authenticator = authenticator; - if (string.IsNullOrEmpty(credentials.Url)) + if (string.IsNullOrEmpty(Url)) { - credentials.Url = defaultUrl; + Authenticator.Url = defaultUrl; } + Authenticator.Url = Url; } else { - throw new IBMException("Please provide a username and password or authorization token to use the CompareComply service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-credentials"); + throw new IBMException("Please provide a username and password or authorization token to use the CompareComply service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-authenticator"); } } @@ -133,21 +128,18 @@ public CompareComplyService(string versionDate, Credentials credentials) : base( /// /// The callback function that is invoked when the operation completes. /// The document to convert. - /// The filename for file. /// The content type of file. (optional) /// The analysis model to be used by the service. For the **Element classification** and /// **Compare two documents** methods, the default is `contracts`. For the **Extract tables** method, the /// default is `tables`. These defaults apply to the standalone methods as well as to the methods' use in /// batch-processing requests. (optional) /// HTMLReturn - public bool ConvertToHtml(Callback callback, System.IO.MemoryStream file, string filename, string fileContentType = null, string model = null) + public bool ConvertToHtml(Callback callback, System.IO.MemoryStream file, string fileContentType = null, string model = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `ConvertToHtml`"); if (file == null) throw new ArgumentNullException("`file` is required for `ConvertToHtml`"); - if (string.IsNullOrEmpty(filename)) - throw new ArgumentNullException("`filename` is required for `ConvertToHtml`"); RequestObject req = new RequestObject { @@ -172,7 +164,7 @@ public bool ConvertToHtml(Callback callback, System.IO.MemoryStream req.Forms = new Dictionary(); if (file != null) { - req.Forms["file"] = new RESTConnector.Form(file, filename, fileContentType); + req.Forms["file"] = new RESTConnector.Form(file, "filename", fileContentType); } if (!string.IsNullOrEmpty(model)) { @@ -181,11 +173,12 @@ public bool ConvertToHtml(Callback callback, System.IO.MemoryStream req.OnResponse = OnConvertToHtmlResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/html_conversion"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/html_conversion"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -266,11 +259,12 @@ public bool ClassifyElements(Callback callback, System.IO.Memory req.OnResponse = OnClassifyElementsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/element_classification"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/element_classification"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -351,11 +345,12 @@ public bool ExtractTables(Callback callback, System.IO.MemoryStream req.OnResponse = OnExtractTablesResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/tables"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/tables"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -454,11 +449,12 @@ public bool CompareDocuments(Callback callback, System.IO.MemoryS req.OnResponse = OnCompareDocumentsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/comparison"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/comparison"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -541,11 +537,12 @@ public bool AddFeedback(Callback callback, FeedbackDataInput fee req.OnResponse = OnAddFeedbackResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/feedback"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/feedback"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -713,11 +710,12 @@ public bool ListFeedback(Callback callback, string feedbackType = req.OnResponse = OnListFeedbackResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/feedback"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/feedback"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -792,11 +790,12 @@ public bool GetFeedback(Callback callback, string feedbackId, strin req.OnResponse = OnGetFeedbackResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/feedback/{0}", feedbackId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/feedback/{0}", feedbackId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -871,11 +870,12 @@ public bool DeleteFeedback(Callback callback, string feedbackId req.OnResponse = OnDeleteFeedbackResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/feedback/{0}", feedbackId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/feedback/{0}", feedbackId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1010,11 +1010,12 @@ public bool CreateBatch(Callback callback, string function, System. req.OnResponse = OnCreateBatchResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/batches"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/batches"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1078,11 +1079,12 @@ public bool ListBatches(Callback callback) req.OnResponse = OnListBatchesResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/batches"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/batches"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1149,11 +1151,12 @@ public bool GetBatch(Callback callback, string batchId) req.OnResponse = OnGetBatchResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/batches/{0}", batchId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/batches/{0}", batchId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1236,11 +1239,12 @@ public bool UpdateBatch(Callback callback, string batchId, string a req.OnResponse = OnUpdateBatchResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/batches/{0}", batchId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/batches/{0}", batchId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } diff --git a/Scripts/Services/Discovery/V1/DiscoveryService.cs b/Scripts/Services/Discovery/V1/DiscoveryService.cs index 53d4730fa..6f47698ce 100644 --- a/Scripts/Services/Discovery/V1/DiscoveryService.cs +++ b/Scripts/Services/Discovery/V1/DiscoveryService.cs @@ -18,6 +18,7 @@ using System.Collections.Generic; using System.Text; using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; using IBM.Cloud.SDK.Connection; using IBM.Cloud.SDK.Utilities; using IBM.Watson.Discovery.V1.Model; @@ -33,20 +34,16 @@ public partial class DiscoveryService : BaseService private const string serviceId = "discovery"; private const string defaultUrl = "https://gateway.watsonplatform.net/discovery/api"; - #region Credentials + #region Authenticator /// - /// Gets and sets the credentials of the service. Replace the default endpoint if endpoint is defined. + /// Gets and sets the authenticator of the service. Replace the default endpoint if endpoint is defined. /// - public Credentials Credentials + public Authenticator Authenticator { - get { return credentials; } + get { return authenticator; } set { - credentials = value; - if (!string.IsNullOrEmpty(credentials.Url)) - { - Url = credentials.Url; - } + authenticator = value; } } #endregion @@ -90,17 +87,14 @@ public bool DisableSslVerification /// DiscoveryService constructor. /// /// The service version date in `yyyy-mm-dd` format. - public DiscoveryService(string versionDate) : base(versionDate, serviceId) - { - VersionDate = versionDate; - } + public DiscoveryService(string versionDate) : this(versionDate, ConfigBasedAuthenticatorFactory.GetAuthenticator(serviceId)) {} /// /// DiscoveryService constructor. /// /// The service version date in `yyyy-mm-dd` format. - /// The service credentials. - public DiscoveryService(string versionDate, Credentials credentials) : base(versionDate, credentials, serviceId) + /// The service authenticator. + public DiscoveryService(string versionDate, Authenticator authenticator) : base(versionDate, authenticator, serviceId) { if (string.IsNullOrEmpty(versionDate)) { @@ -111,18 +105,19 @@ public DiscoveryService(string versionDate, Credentials credentials) : base(vers VersionDate = versionDate; } - if (credentials.HasCredentials() || credentials.HasTokenData()) + if (authenticator != null) { - Credentials = credentials; + Authenticator = authenticator; - if (string.IsNullOrEmpty(credentials.Url)) + if (string.IsNullOrEmpty(Url)) { - credentials.Url = defaultUrl; + Authenticator.Url = defaultUrl; } + Authenticator.Url = Url; } else { - throw new IBMException("Please provide a username and password or authorization token to use the Discovery service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-credentials"); + throw new IBMException("Please provide a username and password or authorization token to use the Discovery service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-authenticator"); } } @@ -182,11 +177,12 @@ public bool CreateEnvironment(Callback callback, string name, req.OnResponse = OnCreateEnvironmentResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/environments"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/environments"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -255,11 +251,12 @@ public bool ListEnvironments(Callback callback, string req.OnResponse = OnListEnvironmentsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/environments"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/environments"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -324,11 +321,12 @@ public bool GetEnvironment(Callback callback, string environme req.OnResponse = OnGetEnvironmentResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}", environmentId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}", environmentId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -411,11 +409,12 @@ public bool UpdateEnvironment(Callback callback, string enviro req.OnResponse = OnUpdateEnvironmentResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}", environmentId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}", environmentId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -480,11 +479,12 @@ public bool DeleteEnvironment(Callback callback, stri req.OnResponse = OnDeleteEnvironmentResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}", environmentId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}", environmentId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -558,11 +558,12 @@ public bool ListFields(Callback callback, string e req.OnResponse = OnListFieldsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/fields", environmentId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/fields", environmentId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -663,11 +664,12 @@ public bool CreateConfiguration(Callback callback, string environ req.OnResponse = OnCreateConfigurationResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/configurations", environmentId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/configurations", environmentId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -739,11 +741,12 @@ public bool ListConfigurations(Callback callback, st req.OnResponse = OnListConfigurationsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/configurations", environmentId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/configurations", environmentId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -811,11 +814,12 @@ public bool GetConfiguration(Callback callback, string environmen req.OnResponse = OnGetConfigurationResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/configurations/{1}", environmentId, configurationId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/configurations/{1}", environmentId, configurationId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -918,11 +922,12 @@ public bool UpdateConfiguration(Callback callback, string environ req.OnResponse = OnUpdateConfigurationResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/configurations/{1}", environmentId, configurationId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/configurations/{1}", environmentId, configurationId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -995,11 +1000,12 @@ public bool DeleteConfiguration(Callback callback, req.OnResponse = OnDeleteConfigurationResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/configurations/{1}", environmentId, configurationId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/configurations/{1}", environmentId, configurationId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1042,16 +1048,15 @@ private void OnDeleteConfigurationResponse(RESTConnector.Request req, RESTConnec /// The configuration to use to process the document. If this part is provided, then /// the provided configuration is used to process the document. If the **configuration_id** is also provided /// (both are present at the same time), then request is rejected. The maximum supported configuration size is 1 - /// MB. Configuration parts larger than 1 MB are rejected. - /// See the `GET /configurations/{configuration_id}` operation for an example configuration. (optional) + /// MB. Configuration parts larger than 1 MB are rejected. See the `GET /configurations/{configuration_id}` + /// operation for an example configuration. (optional) /// The content of the document to ingest. The maximum supported file size when adding a file /// to a collection is 50 megabytes, the maximum supported file size when testing a confiruration is 1 megabyte. /// Files larger than the supported size are rejected. (optional) /// The filename for file. (optional) /// The content type of file. (optional) /// The maximum supported metadata file size is 1 MB. Metadata parts larger than 1 MB are - /// rejected. - /// Example: ``` { + /// rejected. Example: ``` { /// "Creator": "Johnny Appleseed", /// "Subject": "Apples" /// } ```. (optional) @@ -1113,11 +1118,12 @@ public bool TestConfigurationInEnvironment(Callback callback, stri req.OnResponse = OnTestConfigurationInEnvironmentResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/preview", environmentId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/preview", environmentId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1203,11 +1209,12 @@ public bool CreateCollection(Callback callback, string environmentId req.OnResponse = OnCreateCollectionResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections", environmentId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections", environmentId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1279,11 +1286,12 @@ public bool ListCollections(Callback callback, string e req.OnResponse = OnListCollectionsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections", environmentId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections", environmentId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1351,11 +1359,12 @@ public bool GetCollection(Callback callback, string environmentId, s req.OnResponse = OnGetCollectionResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}", environmentId, collectionId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}", environmentId, collectionId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1438,11 +1447,12 @@ public bool UpdateCollection(Callback callback, string environmentId req.OnResponse = OnUpdateCollectionResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}", environmentId, collectionId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}", environmentId, collectionId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1510,11 +1520,12 @@ public bool DeleteCollection(Callback callback, string req.OnResponse = OnDeleteCollectionResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}", environmentId, collectionId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}", environmentId, collectionId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1584,11 +1595,12 @@ public bool ListCollectionFields(Callback callback req.OnResponse = OnListCollectionFieldsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}/fields", environmentId, collectionId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/fields", environmentId, collectionId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1659,11 +1671,12 @@ public bool ListExpansions(Callback callback, string environmentId, req.OnResponse = OnListExpansionsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}/expansions", environmentId, collectionId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/expansions", environmentId, collectionId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1696,8 +1709,7 @@ private void OnListExpansionsResponse(RESTConnector.Request req, RESTConnector.R /// Create or update expansion list. /// /// Create or replace the Expansion list for this collection. The maximum number of expanded terms per - /// collection is `500`. - /// The current expansion list is replaced with the uploaded content. + /// collection is `500`. The current expansion list is replaced with the uploaded content. /// /// The callback function that is invoked when the operation completes. /// The ID of the environment. @@ -1757,11 +1769,12 @@ public bool CreateExpansions(Callback callback, string environmentId req.OnResponse = OnCreateExpansionsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}/expansions", environmentId, collectionId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/expansions", environmentId, collectionId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1832,11 +1845,12 @@ public bool DeleteExpansions(Callback callback, string environmentId, st req.OnResponse = OnDeleteExpansionsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}/expansions", environmentId, collectionId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/expansions", environmentId, collectionId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1906,11 +1920,12 @@ public bool GetTokenizationDictionaryStatus(Callback ca req.OnResponse = OnGetTokenizationDictionaryStatusResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}/word_lists/tokenization_dictionary", environmentId, collectionId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/word_lists/tokenization_dictionary", environmentId, collectionId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1990,11 +2005,12 @@ public bool CreateTokenizationDictionary(Callback callb req.OnResponse = OnCreateTokenizationDictionaryResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}/word_lists/tokenization_dictionary", environmentId, collectionId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/word_lists/tokenization_dictionary", environmentId, collectionId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -2064,11 +2080,12 @@ public bool DeleteTokenizationDictionary(Callback callback, string envir req.OnResponse = OnDeleteTokenizationDictionaryResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}/word_lists/tokenization_dictionary", environmentId, collectionId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/word_lists/tokenization_dictionary", environmentId, collectionId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -2138,11 +2155,12 @@ public bool GetStopwordListStatus(Callback callback, st req.OnResponse = OnGetStopwordListStatusResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}/word_lists/stopwords", environmentId, collectionId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/word_lists/stopwords", environmentId, collectionId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -2223,11 +2241,12 @@ public bool CreateStopwordList(Callback callback, strin req.OnResponse = OnCreateStopwordListResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}/word_lists/stopwords", environmentId, collectionId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/word_lists/stopwords", environmentId, collectionId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -2298,11 +2317,12 @@ public bool DeleteStopwordList(Callback callback, string environmentId, req.OnResponse = OnDeleteStopwordListResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}/word_lists/stopwords", environmentId, collectionId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/word_lists/stopwords", environmentId, collectionId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -2367,8 +2387,7 @@ private void OnDeleteStopwordListResponse(RESTConnector.Request req, RESTConnect /// The filename for file. (optional) /// The content type of file. (optional) /// The maximum supported metadata file size is 1 MB. Metadata parts larger than 1 MB are - /// rejected. - /// Example: ``` { + /// rejected. Example: ``` { /// "Creator": "Johnny Appleseed", /// "Subject": "Apples" /// } ```. (optional) @@ -2414,11 +2433,12 @@ public bool AddDocument(Callback callback, string environmentI req.OnResponse = OnAddDocumentResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}/documents", environmentId, collectionId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/documents", environmentId, collectionId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -2493,11 +2513,12 @@ public bool GetDocumentStatus(Callback callback, string environm req.OnResponse = OnGetDocumentStatusResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}/documents/{2}", environmentId, collectionId, documentId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/documents/{2}", environmentId, collectionId, documentId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -2545,8 +2566,7 @@ private void OnGetDocumentStatusResponse(RESTConnector.Request req, RESTConnecto /// The filename for file. (optional) /// The content type of file. (optional) /// The maximum supported metadata file size is 1 MB. Metadata parts larger than 1 MB are - /// rejected. - /// Example: ``` { + /// rejected. Example: ``` { /// "Creator": "Johnny Appleseed", /// "Subject": "Apples" /// } ```. (optional) @@ -2594,11 +2614,12 @@ public bool UpdateDocument(Callback callback, string environme req.OnResponse = OnUpdateDocumentResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}/documents/{2}", environmentId, collectionId, documentId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/documents/{2}", environmentId, collectionId, documentId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -2672,11 +2693,12 @@ public bool DeleteDocument(Callback callback, string env req.OnResponse = OnDeleteDocumentResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}/documents/{2}", environmentId, collectionId, documentId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/documents/{2}", environmentId, collectionId, documentId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -2728,7 +2750,7 @@ private void OnDeleteDocumentResponse(RESTConnector.Request req, RESTConnector.R /// filters. Useful for applications to build lists, tables, and time series. For a full list of possible /// aggregations, see the Query reference. (optional) /// Number of results to return. (optional) - /// A comma-separated list of the portion of the document hierarchy to return. + /// A comma-separated list of the portion of the document hierarchy to return. /// (optional) /// The number of query results to skip at the beginning. For example, if the total number /// of results that are returned is 10 and the offset is 8, it returns the last two results. (optional) @@ -2768,10 +2790,10 @@ private void OnDeleteDocumentResponse(RESTConnector.Request req, RESTConnector.R /// towards field values closer to the current date. When a **number** type field is specified, returned results /// are biased towards higher field values. This parameter cannot be used in the same query as the **sort** /// parameter. (optional) - /// If `true`, queries are not stored in the Discovery **Logs** endpoint. (optional, - /// default to false) + /// If `true`, queries are not stored in the Discovery **Logs** endpoint. + /// (optional, default to false) /// QueryResponse - public bool Query(Callback callback, string environmentId, string collectionId, string filter = null, string query = null, string naturalLanguageQuery = null, bool? passages = null, string aggregation = null, long? count = null, string returnFields = null, long? offset = null, string sort = null, bool? highlight = null, string passagesFields = null, long? passagesCount = null, long? passagesCharacters = null, bool? deduplicate = null, string deduplicateField = null, string collectionIds = null, bool? similar = null, string similarDocumentIds = null, string similarFields = null, string bias = null, bool? loggingOptOut = null) + public bool Query(Callback callback, string environmentId, string collectionId, string filter = null, string query = null, string naturalLanguageQuery = null, bool? passages = null, string aggregation = null, long? count = null, string _return = null, long? offset = null, string sort = null, bool? highlight = null, string passagesFields = null, long? passagesCount = null, long? passagesCharacters = null, bool? deduplicate = null, string deduplicateField = null, string collectionIds = null, bool? similar = null, string similarDocumentIds = null, string similarFields = null, string bias = null, bool? xWatsonLoggingOptOut = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `Query`"); @@ -2803,9 +2825,9 @@ public bool Query(Callback callback, string environmentId, string req.Headers["Content-Type"] = "application/json"; req.Headers["Accept"] = "application/json"; - if (loggingOptOut != null) + if (xWatsonLoggingOptOut != null) { - req.Headers["X-Watson-Logging-Opt-Out"] = (bool)loggingOptOut ? "true" : "false"; + req.Headers["X-Watson-Logging-Opt-Out"] = (bool)xWatsonLoggingOptOut ? "true" : "false"; } JObject bodyObject = new JObject(); @@ -2821,8 +2843,8 @@ public bool Query(Callback callback, string environmentId, string bodyObject["aggregation"] = aggregation; if (count != null) bodyObject["count"] = JToken.FromObject(count); - if (!string.IsNullOrEmpty(returnFields)) - bodyObject["return"] = returnFields; + if (!string.IsNullOrEmpty(_return)) + bodyObject["return"] = _return; if (offset != null) bodyObject["offset"] = JToken.FromObject(offset); if (!string.IsNullOrEmpty(sort)) @@ -2853,11 +2875,12 @@ public bool Query(Callback callback, string environmentId, string req.OnResponse = OnQueryResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}/query", environmentId, collectionId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/query", environmentId, collectionId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -2911,7 +2934,7 @@ private void OnQueryResponse(RESTConnector.Request req, RESTConnector.Response r /// aggregations, see the Query reference. (optional) /// Number of results to return. The maximum for the **count** and **offset** values /// together in any one query is **10000**. (optional) - /// A comma-separated list of the portion of the document hierarchy to return. + /// A comma-separated list of the portion of the document hierarchy to return. /// (optional) /// The number of query results to skip at the beginning. For example, if the total number /// of results that are returned is 10 and the offset is 8, it returns the last two results. The maximum for the @@ -2941,7 +2964,7 @@ private void OnQueryResponse(RESTConnector.Request req, RESTConnector.Response r /// A comma-separated list of field names that are used as a basis for comparison to /// identify similar documents. If not specified, the entire document is used for comparison. (optional) /// QueryNoticesResponse - public bool QueryNotices(Callback callback, string environmentId, string collectionId, string filter = null, string query = null, string naturalLanguageQuery = null, bool? passages = null, string aggregation = null, long? count = null, List returnFields = null, long? offset = null, List sort = null, bool? highlight = null, List passagesFields = null, long? passagesCount = null, long? passagesCharacters = null, string deduplicateField = null, bool? similar = null, List similarDocumentIds = null, List similarFields = null) + public bool QueryNotices(Callback callback, string environmentId, string collectionId, string filter = null, string query = null, string naturalLanguageQuery = null, bool? passages = null, string aggregation = null, long? count = null, List _return = null, long? offset = null, List sort = null, bool? highlight = null, List passagesFields = null, long? passagesCount = null, long? passagesCharacters = null, string deduplicateField = null, bool? similar = null, List similarDocumentIds = null, List similarFields = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `QueryNotices`"); @@ -2994,9 +3017,9 @@ public bool QueryNotices(Callback callback, string environ { req.Parameters["count"] = count; } - if (returnFields != null && returnFields.Count > 0) + if (_return != null && _return.Count > 0) { - req.Parameters["return"] = string.Join(",", returnFields.ToArray()); + req.Parameters["return"] = string.Join(",", _return.ToArray()); } if (offset != null) { @@ -3041,11 +3064,12 @@ public bool QueryNotices(Callback callback, string environ req.OnResponse = OnQueryNoticesResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}/notices", environmentId, collectionId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/notices", environmentId, collectionId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -3097,7 +3121,7 @@ private void OnQueryNoticesResponse(RESTConnector.Request req, RESTConnector.Res /// filters. Useful for applications to build lists, tables, and time series. For a full list of possible /// aggregations, see the Query reference. (optional) /// Number of results to return. (optional) - /// A comma-separated list of the portion of the document hierarchy to return. + /// A comma-separated list of the portion of the document hierarchy to return. /// (optional) /// The number of query results to skip at the beginning. For example, if the total number /// of results that are returned is 10 and the offset is 8, it returns the last two results. (optional) @@ -3137,10 +3161,10 @@ private void OnQueryNoticesResponse(RESTConnector.Request req, RESTConnector.Res /// towards field values closer to the current date. When a **number** type field is specified, returned results /// are biased towards higher field values. This parameter cannot be used in the same query as the **sort** /// parameter. (optional) - /// If `true`, queries are not stored in the Discovery **Logs** endpoint. (optional, - /// default to false) + /// If `true`, queries are not stored in the Discovery **Logs** endpoint. + /// (optional, default to false) /// QueryResponse - public bool FederatedQuery(Callback callback, string environmentId, string filter = null, string query = null, string naturalLanguageQuery = null, bool? passages = null, string aggregation = null, long? count = null, string returnFields = null, long? offset = null, string sort = null, bool? highlight = null, string passagesFields = null, long? passagesCount = null, long? passagesCharacters = null, bool? deduplicate = null, string deduplicateField = null, string collectionIds = null, bool? similar = null, string similarDocumentIds = null, string similarFields = null, string bias = null, bool? loggingOptOut = null) + public bool FederatedQuery(Callback callback, string environmentId, string filter = null, string query = null, string naturalLanguageQuery = null, bool? passages = null, string aggregation = null, long? count = null, string _return = null, long? offset = null, string sort = null, bool? highlight = null, string passagesFields = null, long? passagesCount = null, long? passagesCharacters = null, bool? deduplicate = null, string deduplicateField = null, string collectionIds = null, bool? similar = null, string similarDocumentIds = null, string similarFields = null, string bias = null, bool? xWatsonLoggingOptOut = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `FederatedQuery`"); @@ -3170,9 +3194,9 @@ public bool FederatedQuery(Callback callback, string environmentI req.Headers["Content-Type"] = "application/json"; req.Headers["Accept"] = "application/json"; - if (loggingOptOut != null) + if (xWatsonLoggingOptOut != null) { - req.Headers["X-Watson-Logging-Opt-Out"] = (bool)loggingOptOut ? "true" : "false"; + req.Headers["X-Watson-Logging-Opt-Out"] = (bool)xWatsonLoggingOptOut ? "true" : "false"; } JObject bodyObject = new JObject(); @@ -3188,8 +3212,8 @@ public bool FederatedQuery(Callback callback, string environmentI bodyObject["aggregation"] = aggregation; if (count != null) bodyObject["count"] = JToken.FromObject(count); - if (!string.IsNullOrEmpty(returnFields)) - bodyObject["return"] = returnFields; + if (!string.IsNullOrEmpty(_return)) + bodyObject["return"] = _return; if (offset != null) bodyObject["offset"] = JToken.FromObject(offset); if (!string.IsNullOrEmpty(sort)) @@ -3220,11 +3244,12 @@ public bool FederatedQuery(Callback callback, string environmentI req.OnResponse = OnFederatedQueryResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/query", environmentId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/query", environmentId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -3276,7 +3301,7 @@ private void OnFederatedQueryResponse(RESTConnector.Request req, RESTConnector.R /// aggregations, see the Query reference. (optional) /// Number of results to return. The maximum for the **count** and **offset** values /// together in any one query is **10000**. (optional) - /// A comma-separated list of the portion of the document hierarchy to return. + /// A comma-separated list of the portion of the document hierarchy to return. /// (optional) /// The number of query results to skip at the beginning. For example, if the total number /// of results that are returned is 10 and the offset is 8, it returns the last two results. The maximum for the @@ -3300,7 +3325,7 @@ private void OnFederatedQueryResponse(RESTConnector.Request req, RESTConnector.R /// A comma-separated list of field names that are used as a basis for comparison to /// identify similar documents. If not specified, the entire document is used for comparison. (optional) /// QueryNoticesResponse - public bool FederatedQueryNotices(Callback callback, string environmentId, List collectionIds, string filter = null, string query = null, string naturalLanguageQuery = null, string aggregation = null, long? count = null, List returnFields = null, long? offset = null, List sort = null, bool? highlight = null, string deduplicateField = null, bool? similar = null, List similarDocumentIds = null, List similarFields = null) + public bool FederatedQueryNotices(Callback callback, string environmentId, List collectionIds, string filter = null, string query = null, string naturalLanguageQuery = null, string aggregation = null, long? count = null, List _return = null, long? offset = null, List sort = null, bool? highlight = null, string deduplicateField = null, bool? similar = null, List similarDocumentIds = null, List similarFields = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `FederatedQueryNotices`"); @@ -3353,9 +3378,9 @@ public bool FederatedQueryNotices(Callback callback, strin { req.Parameters["count"] = count; } - if (returnFields != null && returnFields.Count > 0) + if (_return != null && _return.Count > 0) { - req.Parameters["return"] = string.Join(",", returnFields.ToArray()); + req.Parameters["return"] = string.Join(",", _return.ToArray()); } if (offset != null) { @@ -3388,11 +3413,12 @@ public bool FederatedQueryNotices(Callback callback, strin req.OnResponse = OnFederatedQueryNoticesResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/notices", environmentId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/notices", environmentId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -3488,11 +3514,12 @@ public bool QueryEntities(Callback callback, string envir req.OnResponse = OnQueryEntitiesResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}/query_entities", environmentId, collectionId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/query_entities", environmentId, collectionId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -3592,11 +3619,12 @@ public bool QueryRelations(Callback callback, string env req.OnResponse = OnQueryRelationsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}/query_relations", environmentId, collectionId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/query_relations", environmentId, collectionId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -3666,11 +3694,12 @@ public bool ListTrainingData(Callback callback, string environm req.OnResponse = OnListTrainingDataResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}/training_data", environmentId, collectionId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/training_data", environmentId, collectionId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -3756,11 +3785,12 @@ public bool AddTrainingData(Callback callback, string environment req.OnResponse = OnAddTrainingDataResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}/training_data", environmentId, collectionId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/training_data", environmentId, collectionId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -3830,11 +3860,12 @@ public bool DeleteAllTrainingData(Callback callback, string environmentI req.OnResponse = OnDeleteAllTrainingDataResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}/training_data", environmentId, collectionId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/training_data", environmentId, collectionId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -3907,11 +3938,12 @@ public bool GetTrainingData(Callback callback, string environment req.OnResponse = OnGetTrainingDataResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}/training_data/{2}", environmentId, collectionId, queryId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/training_data/{2}", environmentId, collectionId, queryId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -3984,11 +4016,12 @@ public bool DeleteTrainingData(Callback callback, string environmentId, req.OnResponse = OnDeleteTrainingDataResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}/training_data/{2}", environmentId, collectionId, queryId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/training_data/{2}", environmentId, collectionId, queryId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -4061,11 +4094,12 @@ public bool ListTrainingExamples(Callback callback, string req.OnResponse = OnListTrainingExamplesResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}/training_data/{2}/examples", environmentId, collectionId, queryId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/training_data/{2}/examples", environmentId, collectionId, queryId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -4152,11 +4186,12 @@ public bool CreateTrainingExample(Callback callback, string env req.OnResponse = OnCreateTrainingExampleResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}/training_data/{2}/examples", environmentId, collectionId, queryId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/training_data/{2}/examples", environmentId, collectionId, queryId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -4232,11 +4267,12 @@ public bool DeleteTrainingExample(Callback callback, string environmentI req.OnResponse = OnDeleteTrainingExampleResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}/training_data/{2}/examples/{3}", environmentId, collectionId, queryId, exampleId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/training_data/{2}/examples/{3}", environmentId, collectionId, queryId, exampleId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -4323,11 +4359,12 @@ public bool UpdateTrainingExample(Callback callback, string env req.OnResponse = OnUpdateTrainingExampleResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}/training_data/{2}/examples/{3}", environmentId, collectionId, queryId, exampleId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/training_data/{2}/examples/{3}", environmentId, collectionId, queryId, exampleId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -4403,11 +4440,12 @@ public bool GetTrainingExample(Callback callback, string enviro req.OnResponse = OnGetTrainingExampleResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}/training_data/{2}/examples/{3}", environmentId, collectionId, queryId, exampleId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/collections/{1}/training_data/{2}/examples/{3}", environmentId, collectionId, queryId, exampleId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -4483,11 +4521,12 @@ public bool DeleteUserData(Callback callback, string customerId) req.OnResponse = OnDeleteUserDataResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/user_data"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/user_data"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -4567,11 +4606,12 @@ public bool CreateEvent(Callback callback, string type, Eve req.OnResponse = OnCreateEventResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/events"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/events"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -4669,11 +4709,12 @@ public bool QueryLog(Callback callback, string filter = null, req.OnResponse = OnQueryLogResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/logs"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/logs"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -4754,11 +4795,12 @@ public bool GetMetricsQuery(Callback callback, DateTime? startTi req.OnResponse = OnGetMetricsQueryResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/metrics/number_of_queries"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/metrics/number_of_queries"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -4841,11 +4883,12 @@ public bool GetMetricsQueryEvent(Callback callback, DateTime? st req.OnResponse = OnGetMetricsQueryEventResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/metrics/number_of_queries_with_event"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/metrics/number_of_queries_with_event"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -4927,11 +4970,12 @@ public bool GetMetricsQueryNoResults(Callback callback, DateTime req.OnResponse = OnGetMetricsQueryNoResultsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/metrics/number_of_queries_with_no_search_results"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/metrics/number_of_queries_with_no_search_results"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -5014,11 +5058,12 @@ public bool GetMetricsEventRate(Callback callback, DateTime? sta req.OnResponse = OnGetMetricsEventRateResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/metrics/event_rate"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/metrics/event_rate"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -5090,11 +5135,12 @@ public bool GetMetricsQueryTokenEvent(Callback callback, lo req.OnResponse = OnGetMetricsQueryTokenEventResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/metrics/top_query_tokens_with_event_rate"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/metrics/top_query_tokens_with_event_rate"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -5163,11 +5209,12 @@ public bool ListCredentials(Callback callback, string environme req.OnResponse = OnListCredentialsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/credentials", environmentId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/credentials", environmentId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -5262,11 +5309,12 @@ public bool CreateCredentials(Callback callback, string enviro req.OnResponse = OnCreateCredentialsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/credentials", environmentId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/credentials", environmentId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -5339,11 +5387,12 @@ public bool GetCredentials(Callback callback, string environme req.OnResponse = OnGetCredentialsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/credentials/{1}", environmentId, credentialId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/credentials/{1}", environmentId, credentialId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -5440,11 +5489,12 @@ public bool UpdateCredentials(Callback callback, string enviro req.OnResponse = OnUpdateCredentialsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/credentials/{1}", environmentId, credentialId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/credentials/{1}", environmentId, credentialId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -5514,11 +5564,12 @@ public bool DeleteCredentials(Callback callback, string envir req.OnResponse = OnDeleteCredentialsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/credentials/{1}", environmentId, credentialId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/credentials/{1}", environmentId, credentialId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -5585,11 +5636,12 @@ public bool ListGateways(Callback callback, string environmentId) req.OnResponse = OnListGatewaysResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/gateways", environmentId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/gateways", environmentId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -5664,11 +5716,12 @@ public bool CreateGateway(Callback callback, string environmentId, stri req.OnResponse = OnCreateGatewayResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/gateways", environmentId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/gateways", environmentId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -5738,11 +5791,12 @@ public bool GetGateway(Callback callback, string environmentId, string req.OnResponse = OnGetGatewayResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/gateways/{1}", environmentId, gatewayId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/gateways/{1}", environmentId, gatewayId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -5812,11 +5866,12 @@ public bool DeleteGateway(Callback callback, string environmentId req.OnResponse = OnDeleteGatewayResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/gateways/{1}", environmentId, gatewayId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/environments/{0}/gateways/{1}", environmentId, gatewayId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } diff --git a/Scripts/Services/LanguageTranslator/V3/LanguageTranslatorService.cs b/Scripts/Services/LanguageTranslator/V3/LanguageTranslatorService.cs index de3b4d2b7..09eeaa855 100644 --- a/Scripts/Services/LanguageTranslator/V3/LanguageTranslatorService.cs +++ b/Scripts/Services/LanguageTranslator/V3/LanguageTranslatorService.cs @@ -18,6 +18,7 @@ using System.Collections.Generic; using System.Text; using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; using IBM.Cloud.SDK.Connection; using IBM.Cloud.SDK.Utilities; using IBM.Watson.LanguageTranslator.V3.Model; @@ -33,20 +34,16 @@ public partial class LanguageTranslatorService : BaseService private const string serviceId = "language_translator"; private const string defaultUrl = "https://gateway.watsonplatform.net/language-translator/api"; - #region Credentials + #region Authenticator /// - /// Gets and sets the credentials of the service. Replace the default endpoint if endpoint is defined. + /// Gets and sets the authenticator of the service. Replace the default endpoint if endpoint is defined. /// - public Credentials Credentials + public Authenticator Authenticator { - get { return credentials; } + get { return authenticator; } set { - credentials = value; - if (!string.IsNullOrEmpty(credentials.Url)) - { - Url = credentials.Url; - } + authenticator = value; } } #endregion @@ -90,17 +87,14 @@ public bool DisableSslVerification /// LanguageTranslatorService constructor. /// /// The service version date in `yyyy-mm-dd` format. - public LanguageTranslatorService(string versionDate) : base(versionDate, serviceId) - { - VersionDate = versionDate; - } + public LanguageTranslatorService(string versionDate) : this(versionDate, ConfigBasedAuthenticatorFactory.GetAuthenticator(serviceId)) {} /// /// LanguageTranslatorService constructor. /// /// The service version date in `yyyy-mm-dd` format. - /// The service credentials. - public LanguageTranslatorService(string versionDate, Credentials credentials) : base(versionDate, credentials, serviceId) + /// The service authenticator. + public LanguageTranslatorService(string versionDate, Authenticator authenticator) : base(versionDate, authenticator, serviceId) { if (string.IsNullOrEmpty(versionDate)) { @@ -111,18 +105,19 @@ public LanguageTranslatorService(string versionDate, Credentials credentials) : VersionDate = versionDate; } - if (credentials.HasCredentials() || credentials.HasTokenData()) + if (authenticator != null) { - Credentials = credentials; + Authenticator = authenticator; - if (string.IsNullOrEmpty(credentials.Url)) + if (string.IsNullOrEmpty(Url)) { - credentials.Url = defaultUrl; + Authenticator.Url = defaultUrl; } + Authenticator.Url = Url; } else { - throw new IBMException("Please provide a username and password or authorization token to use the LanguageTranslator service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-credentials"); + throw new IBMException("Please provide a username and password or authorization token to use the LanguageTranslator service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-authenticator"); } } @@ -182,11 +177,12 @@ public bool Translate(Callback callback, List text, s req.OnResponse = OnTranslateResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v3/translate"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v3/translate"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -251,11 +247,12 @@ public bool ListIdentifiableLanguages(Callback callback) req.OnResponse = OnListIdentifiableLanguagesResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v3/identifiable_languages"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v3/identifiable_languages"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -325,11 +322,12 @@ public bool Identify(Callback callback, string text) req.OnResponse = OnIdentifyResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v3/identify"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v3/identify"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -366,12 +364,12 @@ private void OnIdentifyResponse(RESTConnector.Request req, RESTConnector.Respons /// The callback function that is invoked when the operation completes. /// Specify a language code to filter results by source language. (optional) /// Specify a language code to filter results by target language. (optional) - /// If the default parameter isn't specified, the service will return all models - /// (default and non-default) for each language pair. To return only default models, set this to `true`. To - /// return only non-default models, set this to `false`. There is exactly one default model per language pair, - /// the IBM provided base model. (optional) + /// If the default parameter isn't specified, the service will return all models (default + /// and non-default) for each language pair. To return only default models, set this to `true`. To return only + /// non-default models, set this to `false`. There is exactly one default model per language pair, the IBM + /// provided base model. (optional) /// TranslationModels - public bool ListModels(Callback callback, string source = null, string target = null, bool? defaultModels = null) + public bool ListModels(Callback callback, string source = null, string target = null, bool? _default = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `ListModels`"); @@ -404,18 +402,19 @@ public bool ListModels(Callback callback, string source = nul { req.Parameters["target"] = target; } - if (defaultModels != null) + if (_default != null) { - req.Parameters["default"] = (bool)defaultModels ? "true" : "false"; + req.Parameters["default"] = (bool)_default ? "true" : "false"; } req.OnResponse = OnListModelsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v3/models"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v3/models"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -523,11 +522,12 @@ public bool CreateModel(Callback callback, string baseModelId, req.OnResponse = OnCreateModelResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v3/models"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v3/models"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -594,11 +594,12 @@ public bool DeleteModel(Callback callback, string modelId) req.OnResponse = OnDeleteModelResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v3/models/{0}", modelId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v3/models/{0}", modelId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -667,11 +668,12 @@ public bool GetModel(Callback callback, string modelId) req.OnResponse = OnGetModelResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v3/models/{0}", modelId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v3/models/{0}", modelId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -735,11 +737,12 @@ public bool ListDocuments(Callback callback) req.OnResponse = OnListDocumentsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v3/documents"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v3/documents"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -843,11 +846,12 @@ public bool TranslateDocument(Callback callback, System.IO.Memor req.OnResponse = OnTranslateDocumentResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v3/documents"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v3/documents"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -914,11 +918,12 @@ public bool GetDocumentStatus(Callback callback, string document req.OnResponse = OnGetDocumentStatusResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v3/documents/{0}", documentId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v3/documents/{0}", documentId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -985,11 +990,12 @@ public bool DeleteDocument(Callback callback, string documentId) req.OnResponse = OnDeleteDocumentResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v3/documents/{0}", documentId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v3/documents/{0}", documentId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1065,11 +1071,12 @@ public bool GetTranslatedDocument(Callback callback, string documentId, req.OnResponse = OnGetTranslatedDocumentResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v3/documents/{0}/translated_document", documentId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v3/documents/{0}/translated_document", documentId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } diff --git a/Scripts/Services/NaturalLanguageClassifier/V1/NaturalLanguageClassifierService.cs b/Scripts/Services/NaturalLanguageClassifier/V1/NaturalLanguageClassifierService.cs index 06e17d66f..7af74c421 100644 --- a/Scripts/Services/NaturalLanguageClassifier/V1/NaturalLanguageClassifierService.cs +++ b/Scripts/Services/NaturalLanguageClassifier/V1/NaturalLanguageClassifierService.cs @@ -18,6 +18,7 @@ using System.Collections.Generic; using System.Text; using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; using IBM.Cloud.SDK.Connection; using IBM.Cloud.SDK.Utilities; using IBM.Watson.NaturalLanguageClassifier.V1.Model; @@ -33,20 +34,16 @@ public partial class NaturalLanguageClassifierService : BaseService private const string serviceId = "natural_language_classifier"; private const string defaultUrl = "https://gateway.watsonplatform.net/natural-language-classifier/api"; - #region Credentials + #region Authenticator /// - /// Gets and sets the credentials of the service. Replace the default endpoint if endpoint is defined. + /// Gets and sets the authenticator of the service. Replace the default endpoint if endpoint is defined. /// - public Credentials Credentials + public Authenticator Authenticator { - get { return credentials; } + get { return authenticator; } set { - credentials = value; - if (!string.IsNullOrEmpty(credentials.Url)) - { - Url = credentials.Url; - } + authenticator = value; } } #endregion @@ -81,30 +78,28 @@ public bool DisableSslVerification /// NaturalLanguageClassifierService constructor. /// - public NaturalLanguageClassifierService() : base(serviceId) - { - - } + public NaturalLanguageClassifierService() : this(ConfigBasedAuthenticatorFactory.GetAuthenticator(serviceId)) {} /// /// NaturalLanguageClassifierService constructor. /// - /// The service credentials. - public NaturalLanguageClassifierService(Credentials credentials) : base(credentials, serviceId) + /// The service authenticator. + public NaturalLanguageClassifierService(Authenticator authenticator) : base(authenticator, serviceId) { - if (credentials.HasCredentials() || credentials.HasTokenData()) + if (authenticator != null) { - Credentials = credentials; + Authenticator = authenticator; - if (string.IsNullOrEmpty(credentials.Url)) + if (string.IsNullOrEmpty(Url)) { - credentials.Url = defaultUrl; + Authenticator.Url = defaultUrl; } + Authenticator.Url = Url; } else { - throw new IBMException("Please provide a username and password or authorization token to use the NaturalLanguageClassifier service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-credentials"); + throw new IBMException("Please provide a username and password or authorization token to use the NaturalLanguageClassifier service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-authenticator"); } } @@ -156,11 +151,12 @@ public bool Classify(Callback callback, string classifierId, str req.OnResponse = OnClassifyResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/classifiers/{0}/classify", classifierId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/classifiers/{0}/classify", classifierId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -239,11 +235,12 @@ public bool ClassifyCollection(Callback callback, stri req.OnResponse = OnClassifyCollectionResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/classifiers/{0}/classify_collection", classifierId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/classifiers/{0}/classify_collection", classifierId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -278,9 +275,9 @@ private void OnClassifyCollectionResponse(RESTConnector.Request req, RESTConnect /// Sends data to create and train a classifier and returns information about the new classifier. /// /// The callback function that is invoked when the operation completes. - /// Metadata in JSON format. The metadata identifies the language of the data, and an - /// optional name to identify the classifier. Specify the language with the 2-letter primary language code as - /// assigned in ISO standard 639. + /// Metadata in JSON format. The metadata identifies the language of the data, + /// and an optional name to identify the classifier. Specify the language with the 2-letter primary language + /// code as assigned in ISO standard 639. /// /// Supported languages are English (`en`), Arabic (`ar`), French (`fr`), German, (`de`), Italian (`it`), /// Japanese (`ja`), Korean (`ko`), Brazilian Portuguese (`pt`), and Spanish (`es`). @@ -288,12 +285,12 @@ private void OnClassifyCollectionResponse(RESTConnector.Request req, RESTConnect /// data can include up to 3,000 classes and 20,000 records. For details, see [Data /// preparation](https://cloud.ibm.com/docs/services/natural-language-classifier?topic=natural-language-classifier-using-your-data). /// Classifier - public bool CreateClassifier(Callback callback, System.IO.MemoryStream metadata, System.IO.MemoryStream trainingData) + public bool CreateClassifier(Callback callback, System.IO.MemoryStream trainingMetadata, System.IO.MemoryStream trainingData) { if (callback == null) throw new ArgumentNullException("`callback` is required for `CreateClassifier`"); - if (metadata == null) - throw new ArgumentNullException("`metadata` is required for `CreateClassifier`"); + if (trainingMetadata == null) + throw new ArgumentNullException("`trainingMetadata` is required for `CreateClassifier`"); if (trainingData == null) throw new ArgumentNullException("`trainingData` is required for `CreateClassifier`"); @@ -317,9 +314,9 @@ public bool CreateClassifier(Callback callback, System.IO.MemoryStre } req.Forms = new Dictionary(); - if (metadata != null) + if (trainingMetadata != null) { - req.Forms["training_metadata"] = new RESTConnector.Form(metadata, "filename", "application/json"); + req.Forms["training_metadata"] = new RESTConnector.Form(trainingMetadata, "filename", "application/json"); } if (trainingData != null) { @@ -328,11 +325,12 @@ public bool CreateClassifier(Callback callback, System.IO.MemoryStre req.OnResponse = OnCreateClassifierResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/classifiers"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/classifiers"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -395,11 +393,12 @@ public bool ListClassifiers(Callback callback) req.OnResponse = OnListClassifiersResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/classifiers"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/classifiers"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -465,11 +464,12 @@ public bool GetClassifier(Callback callback, string classifierId) req.OnResponse = OnGetClassifierResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/classifiers/{0}", classifierId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/classifiers/{0}", classifierId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -533,11 +533,12 @@ public bool DeleteClassifier(Callback callback, string classifierId) req.OnResponse = OnDeleteClassifierResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/classifiers/{0}", classifierId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/classifiers/{0}", classifierId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } diff --git a/Scripts/Services/NaturalLanguageUnderstanding/V1/NaturalLanguageUnderstandingService.cs b/Scripts/Services/NaturalLanguageUnderstanding/V1/NaturalLanguageUnderstandingService.cs index 6c2801238..035102d06 100644 --- a/Scripts/Services/NaturalLanguageUnderstanding/V1/NaturalLanguageUnderstandingService.cs +++ b/Scripts/Services/NaturalLanguageUnderstanding/V1/NaturalLanguageUnderstandingService.cs @@ -18,6 +18,7 @@ using System.Collections.Generic; using System.Text; using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; using IBM.Cloud.SDK.Connection; using IBM.Cloud.SDK.Utilities; using IBM.Watson.NaturalLanguageUnderstanding.V1.Model; @@ -33,20 +34,16 @@ public partial class NaturalLanguageUnderstandingService : BaseService private const string serviceId = "natural_language_understanding"; private const string defaultUrl = "https://gateway.watsonplatform.net/natural-language-understanding/api"; - #region Credentials + #region Authenticator /// - /// Gets and sets the credentials of the service. Replace the default endpoint if endpoint is defined. + /// Gets and sets the authenticator of the service. Replace the default endpoint if endpoint is defined. /// - public Credentials Credentials + public Authenticator Authenticator { - get { return credentials; } + get { return authenticator; } set { - credentials = value; - if (!string.IsNullOrEmpty(credentials.Url)) - { - Url = credentials.Url; - } + authenticator = value; } } #endregion @@ -90,17 +87,14 @@ public bool DisableSslVerification /// NaturalLanguageUnderstandingService constructor. /// /// The service version date in `yyyy-mm-dd` format. - public NaturalLanguageUnderstandingService(string versionDate) : base(versionDate, serviceId) - { - VersionDate = versionDate; - } + public NaturalLanguageUnderstandingService(string versionDate) : this(versionDate, ConfigBasedAuthenticatorFactory.GetAuthenticator(serviceId)) {} /// /// NaturalLanguageUnderstandingService constructor. /// /// The service version date in `yyyy-mm-dd` format. - /// The service credentials. - public NaturalLanguageUnderstandingService(string versionDate, Credentials credentials) : base(versionDate, credentials, serviceId) + /// The service authenticator. + public NaturalLanguageUnderstandingService(string versionDate, Authenticator authenticator) : base(versionDate, authenticator, serviceId) { if (string.IsNullOrEmpty(versionDate)) { @@ -111,18 +105,19 @@ public NaturalLanguageUnderstandingService(string versionDate, Credentials crede VersionDate = versionDate; } - if (credentials.HasCredentials() || credentials.HasTokenData()) + if (authenticator != null) { - Credentials = credentials; + Authenticator = authenticator; - if (string.IsNullOrEmpty(credentials.Url)) + if (string.IsNullOrEmpty(Url)) { - credentials.Url = defaultUrl; + Authenticator.Url = defaultUrl; } + Authenticator.Url = Url; } else { - throw new IBMException("Please provide a username and password or authorization token to use the NaturalLanguageUnderstanding service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-credentials"); + throw new IBMException("Please provide a username and password or authorization token to use the NaturalLanguageUnderstanding service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-authenticator"); } } @@ -225,11 +220,12 @@ public bool Analyze(Callback callback, Features features, strin req.OnResponse = OnAnalyzeResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/analyze"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/analyze"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -295,11 +291,12 @@ public bool ListModels(Callback callback) req.OnResponse = OnListModelsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/models"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/models"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -366,11 +363,12 @@ public bool DeleteModel(Callback callback, string modelId) req.OnResponse = OnDeleteModelResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/models/{0}", modelId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/models/{0}", modelId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } diff --git a/Scripts/Services/PersonalityInsights/V3/PersonalityInsightsService.cs b/Scripts/Services/PersonalityInsights/V3/PersonalityInsightsService.cs index 13586b212..8e5df4446 100644 --- a/Scripts/Services/PersonalityInsights/V3/PersonalityInsightsService.cs +++ b/Scripts/Services/PersonalityInsights/V3/PersonalityInsightsService.cs @@ -18,6 +18,7 @@ using System.Collections.Generic; using System.Text; using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; using IBM.Cloud.SDK.Connection; using IBM.Cloud.SDK.Utilities; using IBM.Watson.PersonalityInsights.V3.Model; @@ -33,20 +34,16 @@ public partial class PersonalityInsightsService : BaseService private const string serviceId = "personality_insights"; private const string defaultUrl = "https://gateway.watsonplatform.net/personality-insights/api"; - #region Credentials + #region Authenticator /// - /// Gets and sets the credentials of the service. Replace the default endpoint if endpoint is defined. + /// Gets and sets the authenticator of the service. Replace the default endpoint if endpoint is defined. /// - public Credentials Credentials + public Authenticator Authenticator { - get { return credentials; } + get { return authenticator; } set { - credentials = value; - if (!string.IsNullOrEmpty(credentials.Url)) - { - Url = credentials.Url; - } + authenticator = value; } } #endregion @@ -90,17 +87,14 @@ public bool DisableSslVerification /// PersonalityInsightsService constructor. /// /// The service version date in `yyyy-mm-dd` format. - public PersonalityInsightsService(string versionDate) : base(versionDate, serviceId) - { - VersionDate = versionDate; - } + public PersonalityInsightsService(string versionDate) : this(versionDate, ConfigBasedAuthenticatorFactory.GetAuthenticator(serviceId)) {} /// /// PersonalityInsightsService constructor. /// /// The service version date in `yyyy-mm-dd` format. - /// The service credentials. - public PersonalityInsightsService(string versionDate, Credentials credentials) : base(versionDate, credentials, serviceId) + /// The service authenticator. + public PersonalityInsightsService(string versionDate, Authenticator authenticator) : base(versionDate, authenticator, serviceId) { if (string.IsNullOrEmpty(versionDate)) { @@ -111,18 +105,19 @@ public PersonalityInsightsService(string versionDate, Credentials credentials) : VersionDate = versionDate; } - if (credentials.HasCredentials() || credentials.HasTokenData()) + if (authenticator != null) { - Credentials = credentials; + Authenticator = authenticator; - if (string.IsNullOrEmpty(credentials.Url)) + if (string.IsNullOrEmpty(Url)) { - credentials.Url = defaultUrl; + Authenticator.Url = defaultUrl; } + Authenticator.Url = Url; } else { - throw new IBMException("Please provide a username and password or authorization token to use the PersonalityInsights service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-credentials"); + throw new IBMException("Please provide a username and password or authorization token to use the PersonalityInsights service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-authenticator"); } } @@ -171,6 +166,8 @@ public PersonalityInsightsService(string versionDate, Credentials credentials) : /// for more information, see [Providing sufficient /// input](https://cloud.ibm.com/docs/services/personality-insights?topic=personality-insights-input#sufficient). /// For JSON input, provide an object of type `Content`. + /// The type of the input. For more information, see **Content types** in the method + /// description. (optional, default to text/plain) /// The language of the input text for the request: Arabic, English, Japanese, /// Korean, or Spanish. Regional variants are treated as their parent language; for example, `en-US` is /// interpreted as `en`. @@ -193,10 +190,8 @@ public PersonalityInsightsService(string versionDate, Credentials credentials) : /// false) /// Indicates whether consumption preferences are returned with the /// results. By default, no consumption preferences are returned. (optional, default to false) - /// The type of the input. For more information, see **Content types** in the method - /// description. (optional, default to text/plain) /// Profile - public bool Profile(Callback callback, Content content, string contentLanguage = null, string acceptLanguage = null, bool? rawScores = null, bool? csvHeaders = null, bool? consumptionPreferences = null, string contentType = null) + public bool Profile(Callback callback, Content content, string contentType = null, string contentLanguage = null, string acceptLanguage = null, bool? rawScores = null, bool? csvHeaders = null, bool? consumptionPreferences = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `Profile`"); @@ -237,6 +232,11 @@ public bool Profile(Callback callback, Content content, string contentL } req.Headers["Accept"] = "application/json"; + if (!string.IsNullOrEmpty(contentType)) + { + req.Headers["Content-Type"] = contentType; + } + if (!string.IsNullOrEmpty(contentLanguage)) { req.Headers["Content-Language"] = contentLanguage; @@ -246,20 +246,16 @@ public bool Profile(Callback callback, Content content, string contentL { req.Headers["Accept-Language"] = acceptLanguage; } - - if (!string.IsNullOrEmpty(contentType)) - { - req.Headers["Content-Type"] = contentType; - } req.Send = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(content)); req.OnResponse = OnProfileResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v3/profile"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v3/profile"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -333,6 +329,8 @@ private void OnProfileResponse(RESTConnector.Request req, RESTConnector.Response /// for more information, see [Providing sufficient /// input](https://cloud.ibm.com/docs/services/personality-insights?topic=personality-insights-input#sufficient). /// For JSON input, provide an object of type `Content`. + /// The type of the input. For more information, see **Content types** in the method + /// description. (optional, default to text/plain) /// The language of the input text for the request: Arabic, English, Japanese, /// Korean, or Spanish. Regional variants are treated as their parent language; for example, `en-US` is /// interpreted as `en`. @@ -355,10 +353,8 @@ private void OnProfileResponse(RESTConnector.Request req, RESTConnector.Response /// false) /// Indicates whether consumption preferences are returned with the /// results. By default, no consumption preferences are returned. (optional, default to false) - /// The type of the input. For more information, see **Content types** in the method - /// description. (optional, default to text/plain) /// System.IO.MemoryStream - public bool ProfileAsCsv(Callback callback, Content content, string contentLanguage = null, string acceptLanguage = null, bool? rawScores = null, bool? csvHeaders = null, bool? consumptionPreferences = null, string contentType = null) + public bool ProfileAsCsv(Callback callback, Content content, string contentType = null, string contentLanguage = null, string acceptLanguage = null, bool? rawScores = null, bool? csvHeaders = null, bool? consumptionPreferences = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `ProfileAsCsv`"); @@ -399,6 +395,11 @@ public bool ProfileAsCsv(Callback callback, Content cont } req.Headers["Accept"] = "text/csv"; + if (!string.IsNullOrEmpty(contentType)) + { + req.Headers["Content-Type"] = contentType; + } + if (!string.IsNullOrEmpty(contentLanguage)) { req.Headers["Content-Language"] = contentLanguage; @@ -408,20 +409,16 @@ public bool ProfileAsCsv(Callback callback, Content cont { req.Headers["Accept-Language"] = acceptLanguage; } - - if (!string.IsNullOrEmpty(contentType)) - { - req.Headers["Content-Type"] = contentType; - } req.Send = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(content)); req.OnResponse = OnProfileAsCsvResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v3/profile"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v3/profile"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } diff --git a/Scripts/Services/SpeechToText/V1/SpeechToTextService.cs b/Scripts/Services/SpeechToText/V1/SpeechToTextService.cs index 06cf1e72e..f38fcb922 100644 --- a/Scripts/Services/SpeechToText/V1/SpeechToTextService.cs +++ b/Scripts/Services/SpeechToText/V1/SpeechToTextService.cs @@ -18,6 +18,7 @@ using System.Collections.Generic; using System.Text; using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; using IBM.Cloud.SDK.Connection; using IBM.Cloud.SDK.Utilities; using IBM.Watson.SpeechToText.V1.Model; @@ -33,20 +34,16 @@ public partial class SpeechToTextService : BaseService private const string serviceId = "speech_to_text"; private const string defaultUrl = "https://stream.watsonplatform.net/speech-to-text/api"; - #region Credentials + #region Authenticator /// - /// Gets and sets the credentials of the service. Replace the default endpoint if endpoint is defined. + /// Gets and sets the authenticator of the service. Replace the default endpoint if endpoint is defined. /// - public Credentials Credentials + public Authenticator Authenticator { - get { return credentials; } + get { return authenticator; } set { - credentials = value; - if (!string.IsNullOrEmpty(credentials.Url)) - { - Url = credentials.Url; - } + authenticator = value; } } #endregion @@ -81,30 +78,28 @@ public bool DisableSslVerification /// SpeechToTextService constructor. /// - public SpeechToTextService() : base(serviceId) - { - - } + public SpeechToTextService() : this(ConfigBasedAuthenticatorFactory.GetAuthenticator(serviceId)) {} /// /// SpeechToTextService constructor. /// - /// The service credentials. - public SpeechToTextService(Credentials credentials) : base(credentials, serviceId) + /// The service authenticator. + public SpeechToTextService(Authenticator authenticator) : base(authenticator, serviceId) { - if (credentials.HasCredentials() || credentials.HasTokenData()) + if (authenticator != null) { - Credentials = credentials; + Authenticator = authenticator; - if (string.IsNullOrEmpty(credentials.Url)) + if (string.IsNullOrEmpty(Url)) { - credentials.Url = defaultUrl; + Authenticator.Url = defaultUrl; } + Authenticator.Url = Url; } else { - throw new IBMException("Please provide a username and password or authorization token to use the SpeechToText service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-credentials"); + throw new IBMException("Please provide a username and password or authorization token to use the SpeechToText service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-authenticator"); } } @@ -146,11 +141,12 @@ public bool ListModels(Callback callback) req.OnResponse = OnListModelsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/models"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/models"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -221,11 +217,12 @@ public bool GetModel(Callback callback, string modelId) req.OnResponse = OnGetModelResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/models/{0}", modelId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/models/{0}", modelId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -334,6 +331,8 @@ private void OnGetModelResponse(RESTConnector.Request req, RESTConnector.Respons /// /// The callback function that is invoked when the operation completes. /// The audio to transcribe. + /// The format (MIME type) of the audio. For more information about specifying an + /// audio format, see **Audio formats (content types)** in the method description. (optional) /// The identifier of the model that is to be used for the recognition request. See /// [Languages and /// models](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-text-models#models). (optional, @@ -430,9 +429,9 @@ private void OnGetModelResponse(RESTConnector.Request req, RESTConnector.Respons /// `speaker_labels` to `true` forces the `timestamps` parameter to be `true`, regardless of whether you specify /// `false` for the parameter. /// - /// **Note:** Applies to US English, Japanese, and Spanish transcription only. To determine whether a language - /// model supports speaker labels, you can also use the **Get a model** method and check that the attribute - /// `speaker_labels` is set to `true`. + /// **Note:** Applies to US English, Japanese, and Spanish (both broadband and narrowband models) and UK English + /// (narrowband model) transcription only. To determine whether a language model supports speaker labels, you + /// can also use the **Get a model** method and check that the attribute `speaker_labels` is set to `true`. /// /// See [Speaker /// labels](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-text-output#speaker_labels). @@ -465,10 +464,8 @@ private void OnGetModelResponse(RESTConnector.Request req, RESTConnector.Respons /// If `true`, requests detailed information about the signal characteristics of the /// input audio. The service returns audio metrics with the final transcription results. By default, the service /// returns no audio metrics. (optional, default to false) - /// The format (MIME type) of the audio. For more information about specifying an - /// audio format, see **Audio formats (content types)** in the method description. (optional) /// SpeechRecognitionResults - public bool Recognize(Callback callback, byte[] audio, string model = null, string languageCustomizationId = null, string acousticCustomizationId = null, string baseModelVersion = null, double? customizationWeight = null, long? inactivityTimeout = null, List keywords = null, float? keywordsThreshold = null, long? maxAlternatives = null, float? wordAlternativesThreshold = null, bool? wordConfidence = null, bool? timestamps = null, bool? profanityFilter = null, bool? smartFormatting = null, bool? speakerLabels = null, string customizationId = null, string grammarName = null, bool? redaction = null, string contentType = null, bool? audioMetrics = null) + public bool Recognize(Callback callback, byte[] audio, string contentType = null, string model = null, string languageCustomizationId = null, string acousticCustomizationId = null, string baseModelVersion = null, double? customizationWeight = null, long? inactivityTimeout = null, List keywords = null, float? keywordsThreshold = null, long? maxAlternatives = null, float? wordAlternativesThreshold = null, bool? wordConfidence = null, bool? timestamps = null, bool? profanityFilter = null, bool? smartFormatting = null, bool? speakerLabels = null, string customizationId = null, string grammarName = null, bool? redaction = null, bool? audioMetrics = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `Recognize`"); @@ -580,11 +577,12 @@ public bool Recognize(Callback callback, byte[] audio, req.OnResponse = OnRecognizeResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/recognize"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/recognize"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -692,11 +690,12 @@ public bool RegisterCallback(Callback callback, string callbackU req.OnResponse = OnRegisterCallbackResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/register_callback"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/register_callback"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -771,11 +770,12 @@ public bool UnregisterCallback(Callback callback, string callbackUrl) req.OnResponse = OnUnregisterCallbackResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/unregister_callback"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/unregister_callback"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -892,6 +892,8 @@ private void OnUnregisterCallbackResponse(RESTConnector.Request req, RESTConnect /// /// The callback function that is invoked when the operation completes. /// The audio to transcribe. + /// The format (MIME type) of the audio. For more information about specifying an + /// audio format, see **Audio formats (content types)** in the method description. (optional) /// The identifier of the model that is to be used for the recognition request. See /// [Languages and /// models](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-text-models#models). (optional, @@ -1019,9 +1021,9 @@ private void OnUnregisterCallbackResponse(RESTConnector.Request req, RESTConnect /// `speaker_labels` to `true` forces the `timestamps` parameter to be `true`, regardless of whether you specify /// `false` for the parameter. /// - /// **Note:** Applies to US English, Japanese, and Spanish transcription only. To determine whether a language - /// model supports speaker labels, you can also use the **Get a model** method and check that the attribute - /// `speaker_labels` is set to `true`. + /// **Note:** Applies to US English, Japanese, and Spanish (both broadband and narrowband models) and UK English + /// (narrowband model) transcription only. To determine whether a language model supports speaker labels, you + /// can also use the **Get a model** method and check that the attribute `speaker_labels` is set to `true`. /// /// See [Speaker /// labels](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-text-output#speaker_labels). @@ -1070,10 +1072,8 @@ private void OnUnregisterCallbackResponse(RESTConnector.Request req, RESTConnect /// If `true`, requests detailed information about the signal characteristics of the /// input audio. The service returns audio metrics with the final transcription results. By default, the service /// returns no audio metrics. (optional, default to false) - /// The format (MIME type) of the audio. For more information about specifying an - /// audio format, see **Audio formats (content types)** in the method description. (optional) /// RecognitionJob - public bool CreateJob(Callback callback, byte[] audio, string model = null, string callbackUrl = null, string events = null, string userToken = null, long? resultsTtl = null, string languageCustomizationId = null, string acousticCustomizationId = null, string baseModelVersion = null, double? customizationWeight = null, long? inactivityTimeout = null, List keywords = null, float? keywordsThreshold = null, long? maxAlternatives = null, float? wordAlternativesThreshold = null, bool? wordConfidence = null, bool? timestamps = null, bool? profanityFilter = null, bool? smartFormatting = null, bool? speakerLabels = null, string customizationId = null, string grammarName = null, bool? redaction = null, string contentType = null, bool? processingMetrics = null, float? processingMetricsInterval = null, bool? audioMetrics = null) + public bool CreateJob(Callback callback, byte[] audio, string contentType = null, string model = null, string callbackUrl = null, string events = null, string userToken = null, long? resultsTtl = null, string languageCustomizationId = null, string acousticCustomizationId = null, string baseModelVersion = null, double? customizationWeight = null, long? inactivityTimeout = null, List keywords = null, float? keywordsThreshold = null, long? maxAlternatives = null, float? wordAlternativesThreshold = null, bool? wordConfidence = null, bool? timestamps = null, bool? profanityFilter = null, bool? smartFormatting = null, bool? speakerLabels = null, string customizationId = null, string grammarName = null, bool? redaction = null, bool? processingMetrics = null, float? processingMetricsInterval = null, bool? audioMetrics = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `CreateJob`"); @@ -1209,11 +1209,12 @@ public bool CreateJob(Callback callback, byte[] audio, string mo req.OnResponse = OnCreateJobResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/recognitions"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/recognitions"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1284,11 +1285,12 @@ public bool CheckJobs(Callback callback) req.OnResponse = OnCheckJobsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/recognitions"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/recognitions"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1366,11 +1368,12 @@ public bool CheckJob(Callback callback, string id) req.OnResponse = OnCheckJobResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/recognitions/{0}", id)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/recognitions/{0}", id)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1443,11 +1446,12 @@ public bool DeleteJob(Callback callback, string id) req.OnResponse = OnDeleteJobResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/recognitions/{0}", id)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/recognitions/{0}", id)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1499,14 +1503,22 @@ private void OnDeleteJobResponse(RESTConnector.Request req, RESTConnector.Respon /// for /// customization](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-text-customization#languageSupport). /// The dialect of the specified language that is to be used with the custom language - /// model. The parameter is meaningful only for Spanish models, for which the service creates a custom language - /// model that is suited for speech in one of the following dialects: - /// * `es-ES` for Castilian Spanish (the default) - /// * `es-LA` for Latin American Spanish - /// * `es-US` for North American (Mexican) Spanish - /// - /// A specified dialect must be valid for the base model. By default, the dialect matches the language of the - /// base model; for example, `en-US` for either of the US English language models. (optional) + /// model. For most languages, the dialect matches the language of the base model by default. For example, + /// `en-US` is used for either of the US English language models. + /// + /// For a Spanish language, the service creates a custom language model that is suited for speech in one of the + /// following dialects: + /// * `es-ES` for Castilian Spanish (`es-ES` models) + /// * `es-LA` for Latin American Spanish (`es-AR`, `es-CL`, `es-CO`, and `es-PE` models) + /// * `es-US` for Mexican (North American) Spanish (`es-MX` models) + /// + /// The parameter is meaningful only for Spanish models, for which you can always safely omit the parameter to + /// have the service create the correct mapping. + /// + /// If you specify the `dialect` parameter for non-Spanish language models, its value must match the language of + /// the base model. If you specify the `dialect` for Spanish language models, its value must match one of the + /// defined mappings as indicated (`es-ES`, `es-LA`, or `es-MX`). All dialect values are case-insensitive. + /// (optional) /// A description of the new custom language model. Use a localized description that /// matches the language of the custom model. (optional) /// LanguageModel @@ -1554,11 +1566,12 @@ public bool CreateLanguageModel(Callback callback, string name, s req.OnResponse = OnCreateLanguageModelResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/customizations"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/customizations"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1634,11 +1647,12 @@ public bool ListLanguageModels(Callback callback, string languag req.OnResponse = OnListLanguageModelsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/customizations"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/customizations"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1710,11 +1724,12 @@ public bool GetLanguageModel(Callback callback, string customizat req.OnResponse = OnGetLanguageModelResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/customizations/{0}", customizationId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/customizations/{0}", customizationId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1787,11 +1802,12 @@ public bool DeleteLanguageModel(Callback callback, string customizationI req.OnResponse = OnDeleteLanguageModelResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/customizations/{0}", customizationId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/customizations/{0}", customizationId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1876,15 +1892,15 @@ private void OnDeleteLanguageModelResponse(RESTConnector.Request req, RESTConnec /// /// The value that you assign is used for all recognition requests that use the model. You can override it for /// any recognition request by specifying a customization weight for that request. (optional) - /// Object - public bool TrainLanguageModel(Callback callback, string customizationId, string wordTypeToAdd = null, double? customizationWeight = null) + /// TrainingResponse + public bool TrainLanguageModel(Callback callback, string customizationId, string wordTypeToAdd = null, double? customizationWeight = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `TrainLanguageModel`"); if (string.IsNullOrEmpty(customizationId)) throw new ArgumentNullException("`customizationId` is required for `TrainLanguageModel`"); - RequestObject req = new RequestObject + RequestObject req = new RequestObject { Callback = callback, HttpMethod = UnityWebRequest.kHttpVerbPOST, @@ -1914,18 +1930,19 @@ public bool TrainLanguageModel(Callback callback, string customizationId req.OnResponse = OnTrainLanguageModelResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/customizations/{0}/train", customizationId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/customizations/{0}/train", customizationId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } private void OnTrainLanguageModelResponse(RESTConnector.Request req, RESTConnector.Response resp) { - DetailedResponse response = new DetailedResponse(); + DetailedResponse response = new DetailedResponse(); foreach (KeyValuePair kvp in resp.Headers) { response.Headers.Add(kvp.Key, kvp.Value); @@ -1935,7 +1952,7 @@ private void OnTrainLanguageModelResponse(RESTConnector.Request req, RESTConnect try { string json = Encoding.UTF8.GetString(resp.Data); - response.Result = JsonConvert.DeserializeObject(json); + response.Result = JsonConvert.DeserializeObject(json); response.Response = json; } catch (Exception e) @@ -1944,8 +1961,8 @@ private void OnTrainLanguageModelResponse(RESTConnector.Request req, RESTConnect resp.Success = false; } - if (((RequestObject)req).Callback != null) - ((RequestObject)req).Callback(response, resp.Error); + if (((RequestObject)req).Callback != null) + ((RequestObject)req).Callback(response, resp.Error); } /// /// Reset a custom language model. @@ -1992,11 +2009,12 @@ public bool ResetLanguageModel(Callback callback, string customizationId req.OnResponse = OnResetLanguageModelResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/customizations/{0}/reset", customizationId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/customizations/{0}/reset", customizationId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -2078,11 +2096,12 @@ public bool UpgradeLanguageModel(Callback callback, string customization req.OnResponse = OnUpgradeLanguageModelResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/customizations/{0}/upgrade_model", customizationId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/customizations/{0}/upgrade_model", customizationId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -2155,11 +2174,12 @@ public bool ListCorpora(Callback callback, string customizationId) req.OnResponse = OnListCorporaResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/customizations/{0}/corpora", customizationId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/customizations/{0}/corpora", customizationId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -2301,11 +2321,12 @@ public bool AddCorpus(Callback callback, string customizationId, string req.OnResponse = OnAddCorpusResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/customizations/{0}/corpora/{1}", customizationId, corpusName)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/customizations/{0}/corpora/{1}", customizationId, corpusName)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -2381,11 +2402,12 @@ public bool GetCorpus(Callback callback, string customizationId, string req.OnResponse = OnGetCorpusResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/customizations/{0}/corpora/{1}", customizationId, corpusName)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/customizations/{0}/corpora/{1}", customizationId, corpusName)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -2464,11 +2486,12 @@ public bool DeleteCorpus(Callback callback, string customizationId, stri req.OnResponse = OnDeleteCorpusResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/customizations/{0}/corpora/{1}", customizationId, corpusName)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/customizations/{0}/corpora/{1}", customizationId, corpusName)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -2563,11 +2586,12 @@ public bool ListWords(Callback callback, string customizationId, string w req.OnResponse = OnListWordsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/customizations/{0}/words", customizationId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/customizations/{0}/words", customizationId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -2690,11 +2714,12 @@ public bool AddWords(Callback callback, string customizationId, List callback, string customizationId, string wo req.OnResponse = OnAddWordResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/customizations/{0}/words/{1}", customizationId, wordName)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/customizations/{0}/words/{1}", customizationId, wordName)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -2907,11 +2933,12 @@ public bool GetWord(Callback callback, string customizationId, string word req.OnResponse = OnGetWordResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/customizations/{0}/words/{1}", customizationId, wordName)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/customizations/{0}/words/{1}", customizationId, wordName)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -2992,11 +3019,12 @@ public bool DeleteWord(Callback callback, string customizationId, string req.OnResponse = OnDeleteWordResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/customizations/{0}/words/{1}", customizationId, wordName)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/customizations/{0}/words/{1}", customizationId, wordName)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -3069,11 +3097,12 @@ public bool ListGrammars(Callback callback, string customizationId) req.OnResponse = OnListGrammarsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/customizations/{0}/grammars", customizationId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/customizations/{0}/grammars", customizationId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -3215,11 +3244,12 @@ public bool AddGrammar(Callback callback, string customizationId, string req.OnResponse = OnAddGrammarResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/customizations/{0}/grammars/{1}", customizationId, grammarName)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/customizations/{0}/grammars/{1}", customizationId, grammarName)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -3295,11 +3325,12 @@ public bool GetGrammar(Callback callback, string customizationId, strin req.OnResponse = OnGetGrammarResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/customizations/{0}/grammars/{1}", customizationId, grammarName)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/customizations/{0}/grammars/{1}", customizationId, grammarName)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -3378,11 +3409,12 @@ public bool DeleteGrammar(Callback callback, string customizationId, str req.OnResponse = OnDeleteGrammarResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/customizations/{0}/grammars/{1}", customizationId, grammarName)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/customizations/{0}/grammars/{1}", customizationId, grammarName)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -3476,11 +3508,12 @@ public bool CreateAcousticModel(Callback callback, string name, s req.OnResponse = OnCreateAcousticModelResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/acoustic_customizations"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/acoustic_customizations"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -3556,11 +3589,12 @@ public bool ListAcousticModels(Callback callback, string languag req.OnResponse = OnListAcousticModelsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/acoustic_customizations"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/acoustic_customizations"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -3632,11 +3666,12 @@ public bool GetAcousticModel(Callback callback, string customizat req.OnResponse = OnGetAcousticModelResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/acoustic_customizations/{0}", customizationId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/acoustic_customizations/{0}", customizationId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -3709,11 +3744,12 @@ public bool DeleteAcousticModel(Callback callback, string customizationI req.OnResponse = OnDeleteAcousticModelResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/acoustic_customizations/{0}", customizationId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/acoustic_customizations/{0}", customizationId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -3798,15 +3834,15 @@ private void OnDeleteAcousticModelResponse(RESTConnector.Request req, RESTConnec /// of the audio resources. The custom language model must be based on the same version of the same base model /// as the custom acoustic model. The credentials specified with the request must own both custom models. /// (optional) - /// Object - public bool TrainAcousticModel(Callback callback, string customizationId, string customLanguageModelId = null) + /// TrainingResponse + public bool TrainAcousticModel(Callback callback, string customizationId, string customLanguageModelId = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `TrainAcousticModel`"); if (string.IsNullOrEmpty(customizationId)) throw new ArgumentNullException("`customizationId` is required for `TrainAcousticModel`"); - RequestObject req = new RequestObject + RequestObject req = new RequestObject { Callback = callback, HttpMethod = UnityWebRequest.kHttpVerbPOST, @@ -3832,18 +3868,19 @@ public bool TrainAcousticModel(Callback callback, string customizationId req.OnResponse = OnTrainAcousticModelResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/acoustic_customizations/{0}/train", customizationId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/acoustic_customizations/{0}/train", customizationId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } private void OnTrainAcousticModelResponse(RESTConnector.Request req, RESTConnector.Response resp) { - DetailedResponse response = new DetailedResponse(); + DetailedResponse response = new DetailedResponse(); foreach (KeyValuePair kvp in resp.Headers) { response.Headers.Add(kvp.Key, kvp.Value); @@ -3853,7 +3890,7 @@ private void OnTrainAcousticModelResponse(RESTConnector.Request req, RESTConnect try { string json = Encoding.UTF8.GetString(resp.Data); - response.Result = JsonConvert.DeserializeObject(json); + response.Result = JsonConvert.DeserializeObject(json); response.Response = json; } catch (Exception e) @@ -3862,8 +3899,8 @@ private void OnTrainAcousticModelResponse(RESTConnector.Request req, RESTConnect resp.Success = false; } - if (((RequestObject)req).Callback != null) - ((RequestObject)req).Callback(response, resp.Error); + if (((RequestObject)req).Callback != null) + ((RequestObject)req).Callback(response, resp.Error); } /// /// Reset a custom acoustic model. @@ -3912,11 +3949,12 @@ public bool ResetAcousticModel(Callback callback, string customizationId req.OnResponse = OnResetAcousticModelResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/acoustic_customizations/{0}/reset", customizationId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/acoustic_customizations/{0}/reset", customizationId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -4023,11 +4061,12 @@ public bool UpgradeAcousticModel(Callback callback, string customization req.OnResponse = OnUpgradeAcousticModelResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/acoustic_customizations/{0}/upgrade_model", customizationId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/acoustic_customizations/{0}/upgrade_model", customizationId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -4102,11 +4141,12 @@ public bool ListAudio(Callback callback, string customizationId) req.OnResponse = OnListAudioResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/acoustic_customizations/{0}/audio", customizationId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/acoustic_customizations/{0}/audio", customizationId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -4243,6 +4283,11 @@ private void OnListAudioResponse(RESTConnector.Request req, RESTConnector.Respon /// individual audio file or an archive file. /// /// With the `curl` command, use the `--data-binary` option to upload the file for the request. + /// For an audio-type resource, the format (MIME type) of the audio. For more + /// information, see **Content types for audio-type resources** in the method description. + /// + /// For an archive-type resource, the media type of the archive file. For more information, see **Content types + /// for archive-type resources** in the method description. (optional) /// **For an archive-type resource,** specify the format of the audio files /// that are contained in the archive file if they are of type `audio/alaw`, `audio/basic`, `audio/l16`, or /// `audio/mulaw`. Include the `rate`, `channels`, and `endianness` parameters where necessary. In this case, @@ -4259,13 +4304,8 @@ private void OnListAudioResponse(RESTConnector.Request req, RESTConnector.Respon /// with the same name. If `false`, the request fails if an audio resource with the same name already exists. /// The parameter has no effect if an audio resource with the same name does not already exist. (optional, /// default to false) - /// For an audio-type resource, the format (MIME type) of the audio. For more - /// information, see **Content types for audio-type resources** in the method description. - /// - /// For an archive-type resource, the media type of the archive file. For more information, see **Content types - /// for archive-type resources** in the method description. (optional) /// object - public bool AddAudio(Callback callback, string customizationId, string audioName, byte[] audioResource, string containedContentType = null, bool? allowOverwrite = null, string contentType = null) + public bool AddAudio(Callback callback, string customizationId, string audioName, byte[] audioResource, string contentType = null, string containedContentType = null, bool? allowOverwrite = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `AddAudio`"); @@ -4301,24 +4341,25 @@ public bool AddAudio(Callback callback, string customizationId, string a } req.Headers["Accept"] = "application/json"; - if (!string.IsNullOrEmpty(containedContentType)) + if (!string.IsNullOrEmpty(contentType)) { - req.Headers["Contained-Content-Type"] = containedContentType; + req.Headers["Content-Type"] = contentType; } - if (!string.IsNullOrEmpty(contentType)) + if (!string.IsNullOrEmpty(containedContentType)) { - req.Headers["Content-Type"] = contentType; + req.Headers["Contained-Content-Type"] = containedContentType; } req.Send = audioResource; req.OnResponse = OnAddAudioResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/acoustic_customizations/{0}/audio/{1}", customizationId, audioName)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/acoustic_customizations/{0}/audio/{1}", customizationId, audioName)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -4407,11 +4448,12 @@ public bool GetAudio(Callback callback, string customizationId, st req.OnResponse = OnGetAudioResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/acoustic_customizations/{0}/audio/{1}", customizationId, audioName)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/acoustic_customizations/{0}/audio/{1}", customizationId, audioName)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -4492,11 +4534,12 @@ public bool DeleteAudio(Callback callback, string customizationId, strin req.OnResponse = OnDeleteAudioResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/acoustic_customizations/{0}/audio/{1}", customizationId, audioName)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/acoustic_customizations/{0}/audio/{1}", customizationId, audioName)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -4575,11 +4618,12 @@ public bool DeleteUserData(Callback callback, string customerId) req.OnResponse = OnDeleteUserDataResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/user_data"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/user_data"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } diff --git a/Scripts/Services/TextToSpeech/V1/TextToSpeechService.cs b/Scripts/Services/TextToSpeech/V1/TextToSpeechService.cs index 053151fc7..33c9c8e72 100644 --- a/Scripts/Services/TextToSpeech/V1/TextToSpeechService.cs +++ b/Scripts/Services/TextToSpeech/V1/TextToSpeechService.cs @@ -18,6 +18,7 @@ using System.Collections.Generic; using System.Text; using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; using IBM.Cloud.SDK.Connection; using IBM.Cloud.SDK.Utilities; using IBM.Watson.TextToSpeech.V1.Model; @@ -33,20 +34,16 @@ public partial class TextToSpeechService : BaseService private const string serviceId = "text_to_speech"; private const string defaultUrl = "https://stream.watsonplatform.net/text-to-speech/api"; - #region Credentials + #region Authenticator /// - /// Gets and sets the credentials of the service. Replace the default endpoint if endpoint is defined. + /// Gets and sets the authenticator of the service. Replace the default endpoint if endpoint is defined. /// - public Credentials Credentials + public Authenticator Authenticator { - get { return credentials; } + get { return authenticator; } set { - credentials = value; - if (!string.IsNullOrEmpty(credentials.Url)) - { - Url = credentials.Url; - } + authenticator = value; } } #endregion @@ -81,30 +78,28 @@ public bool DisableSslVerification /// TextToSpeechService constructor. /// - public TextToSpeechService() : base(serviceId) - { - - } + public TextToSpeechService() : this(ConfigBasedAuthenticatorFactory.GetAuthenticator(serviceId)) {} /// /// TextToSpeechService constructor. /// - /// The service credentials. - public TextToSpeechService(Credentials credentials) : base(credentials, serviceId) + /// The service authenticator. + public TextToSpeechService(Authenticator authenticator) : base(authenticator, serviceId) { - if (credentials.HasCredentials() || credentials.HasTokenData()) + if (authenticator != null) { - Credentials = credentials; + Authenticator = authenticator; - if (string.IsNullOrEmpty(credentials.Url)) + if (string.IsNullOrEmpty(Url)) { - credentials.Url = defaultUrl; + Authenticator.Url = defaultUrl; } + Authenticator.Url = Url; } else { - throw new IBMException("Please provide a username and password or authorization token to use the TextToSpeech service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-credentials"); + throw new IBMException("Please provide a username and password or authorization token to use the TextToSpeech service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-authenticator"); } } @@ -147,11 +142,12 @@ public bool ListVoices(Callback callback) req.OnResponse = OnListVoicesResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/voices"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/voices"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -231,11 +227,12 @@ public bool GetVoice(Callback callback, string voice, string customizatio req.OnResponse = OnGetVoiceResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/voices/{0}", voice)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/voices/{0}", voice)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -348,17 +345,17 @@ private void OnGetVoiceResponse(RESTConnector.Request req, RESTConnector.Respons /// /// The callback function that is invoked when the operation completes. /// The text to synthesize. + /// The requested format (MIME type) of the audio. You can use the `Accept` header or the + /// `accept` parameter to specify the audio format. For more information about specifying an audio format, see + /// **Audio formats (accept types)** in the method description. (optional, default to + /// audio/ogg;codecs=opus) /// The voice to use for synthesis. (optional, default to en-US_MichaelVoice) /// The customization ID (GUID) of a custom voice model to use for the synthesis. /// If a custom voice model is specified, it is guaranteed to work only if it matches the language of the /// indicated voice. You must make the request with credentials for the instance of the service that owns the /// custom model. Omit the parameter to use the specified voice with no customization. (optional) - /// The requested format (MIME type) of the audio. You can use the `Accept` header or the - /// `accept` parameter to specify the audio format. For more information about specifying an audio format, see - /// **Audio formats (accept types)** in the method description. (optional, default to - /// audio/ogg;codecs=opus) /// byte[] - public bool Synthesize(Callback callback, string text, string voice = null, string customizationId = null, string accept = null) + public bool Synthesize(Callback callback, string text, string accept = null, string voice = null, string customizationId = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `Synthesize`"); @@ -407,11 +404,12 @@ public bool Synthesize(Callback callback, string text, string voice = nu req.OnResponse = OnSynthesizeResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/synthesize"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/synthesize"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -501,11 +499,12 @@ public bool GetPronunciation(Callback callback, string text, stri req.OnResponse = OnGetPronunciationResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/pronunciation"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/pronunciation"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -593,11 +592,12 @@ public bool CreateVoiceModel(Callback callback, string name, string req.OnResponse = OnCreateVoiceModelResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/customizations"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/customizations"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -675,11 +675,12 @@ public bool ListVoiceModels(Callback callback, string language = nu req.OnResponse = OnListVoiceModelsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/customizations"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/customizations"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -787,11 +788,12 @@ public bool UpdateVoiceModel(Callback callback, string customizationId, req.OnResponse = OnUpdateVoiceModelResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/customizations/{0}", customizationId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/customizations/{0}", customizationId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -865,11 +867,12 @@ public bool GetVoiceModel(Callback callback, string customizationId) req.OnResponse = OnGetVoiceModelResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/customizations/{0}", customizationId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/customizations/{0}", customizationId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -942,11 +945,12 @@ public bool DeleteVoiceModel(Callback callback, string customizationId) req.OnResponse = OnDeleteVoiceModelResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/customizations/{0}", customizationId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/customizations/{0}", customizationId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1052,11 +1056,12 @@ public bool AddWords(Callback callback, string customizationId, List callback, string customizationId) req.OnResponse = OnListWordsResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/customizations/{0}/words", customizationId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/customizations/{0}/words", customizationId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1247,11 +1253,12 @@ public bool AddWord(Callback callback, string customizationId, string wo req.OnResponse = OnAddWordResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/customizations/{0}/words/{1}", customizationId, word)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/customizations/{0}/words/{1}", customizationId, word)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1328,11 +1335,12 @@ public bool GetWord(Callback callback, string customizationId, stri req.OnResponse = OnGetWordResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/customizations/{0}/words/{1}", customizationId, word)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/customizations/{0}/words/{1}", customizationId, word)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1408,11 +1416,12 @@ public bool DeleteWord(Callback callback, string customizationId, string req.OnResponse = OnDeleteWordResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/customizations/{0}/words/{1}", customizationId, word)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v1/customizations/{0}/words/{1}", customizationId, word)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -1491,11 +1500,12 @@ public bool DeleteUserData(Callback callback, string customerId) req.OnResponse = OnDeleteUserDataResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/user_data"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v1/user_data"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } diff --git a/Scripts/Services/ToneAnalyzer/V3/ToneAnalyzerService.cs b/Scripts/Services/ToneAnalyzer/V3/ToneAnalyzerService.cs index 78c3fab42..c8f8856b2 100644 --- a/Scripts/Services/ToneAnalyzer/V3/ToneAnalyzerService.cs +++ b/Scripts/Services/ToneAnalyzer/V3/ToneAnalyzerService.cs @@ -18,6 +18,7 @@ using System.Collections.Generic; using System.Text; using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; using IBM.Cloud.SDK.Connection; using IBM.Cloud.SDK.Utilities; using IBM.Watson.ToneAnalyzer.V3.Model; @@ -33,20 +34,16 @@ public partial class ToneAnalyzerService : BaseService private const string serviceId = "tone_analyzer"; private const string defaultUrl = "https://gateway.watsonplatform.net/tone-analyzer/api"; - #region Credentials + #region Authenticator /// - /// Gets and sets the credentials of the service. Replace the default endpoint if endpoint is defined. + /// Gets and sets the authenticator of the service. Replace the default endpoint if endpoint is defined. /// - public Credentials Credentials + public Authenticator Authenticator { - get { return credentials; } + get { return authenticator; } set { - credentials = value; - if (!string.IsNullOrEmpty(credentials.Url)) - { - Url = credentials.Url; - } + authenticator = value; } } #endregion @@ -90,17 +87,14 @@ public bool DisableSslVerification /// ToneAnalyzerService constructor. /// /// The service version date in `yyyy-mm-dd` format. - public ToneAnalyzerService(string versionDate) : base(versionDate, serviceId) - { - VersionDate = versionDate; - } + public ToneAnalyzerService(string versionDate) : this(versionDate, ConfigBasedAuthenticatorFactory.GetAuthenticator(serviceId)) {} /// /// ToneAnalyzerService constructor. /// /// The service version date in `yyyy-mm-dd` format. - /// The service credentials. - public ToneAnalyzerService(string versionDate, Credentials credentials) : base(versionDate, credentials, serviceId) + /// The service authenticator. + public ToneAnalyzerService(string versionDate, Authenticator authenticator) : base(versionDate, authenticator, serviceId) { if (string.IsNullOrEmpty(versionDate)) { @@ -111,18 +105,19 @@ public ToneAnalyzerService(string versionDate, Credentials credentials) : base(v VersionDate = versionDate; } - if (credentials.HasCredentials() || credentials.HasTokenData()) + if (authenticator != null) { - Credentials = credentials; + Authenticator = authenticator; - if (string.IsNullOrEmpty(credentials.Url)) + if (string.IsNullOrEmpty(Url)) { - credentials.Url = defaultUrl; + Authenticator.Url = defaultUrl; } + Authenticator.Url = Url; } else { - throw new IBMException("Please provide a username and password or authorization token to use the ToneAnalyzer service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-credentials"); + throw new IBMException("Please provide a username and password or authorization token to use the ToneAnalyzer service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-authenticator"); } } @@ -149,6 +144,8 @@ public ToneAnalyzerService(string versionDate, Credentials credentials) : base(v /// The callback function that is invoked when the operation completes. /// JSON, plain text, or HTML input that contains the content to be analyzed. For JSON /// input, provide an object of type `ToneInput`. + /// The type of the input. A character encoding can be specified by including a + /// `charset` parameter. For example, 'text/plain;charset=utf-8'. (optional) /// Indicates whether the service is to return an analysis of each individual sentence /// in addition to its analysis of the full document. If `true` (the default), the service returns results for /// each sentence. (optional, default to true) @@ -168,10 +165,8 @@ public ToneAnalyzerService(string versionDate, Credentials credentials) : base(v /// The desired language of the response. For two-character arguments, regional /// variants are treated as their parent language; for example, `en-US` is interpreted as `en`. You can use /// different languages for **Content-Language** and **Accept-Language**. (optional, default to en) - /// The type of the input. A character encoding can be specified by including a - /// `charset` parameter. For example, 'text/plain;charset=utf-8'. (optional) /// ToneAnalysis - public bool Tone(Callback callback, ToneInput toneInput, bool? sentences = null, List tones = null, string contentLanguage = null, string acceptLanguage = null, string contentType = null) + public bool Tone(Callback callback, ToneInput toneInput, string contentType = null, bool? sentences = null, List tones = null, string contentLanguage = null, string acceptLanguage = null) { if (callback == null) throw new ArgumentNullException("`callback` is required for `Tone`"); @@ -208,6 +203,11 @@ public bool Tone(Callback callback, ToneInput toneInput, bool? sen } req.Headers["Accept"] = "application/json"; + if (!string.IsNullOrEmpty(contentType)) + { + req.Headers["Content-Type"] = contentType; + } + if (!string.IsNullOrEmpty(contentLanguage)) { req.Headers["Content-Language"] = contentLanguage; @@ -217,20 +217,16 @@ public bool Tone(Callback callback, ToneInput toneInput, bool? sen { req.Headers["Accept-Language"] = acceptLanguage; } - - if (!string.IsNullOrEmpty(contentType)) - { - req.Headers["Content-Type"] = contentType; - } req.Send = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(toneInput)); req.OnResponse = OnToneResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v3/tone"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v3/tone"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -335,11 +331,12 @@ public bool ToneChat(Callback callback, List utter req.OnResponse = OnToneChatResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v3/tone_chat"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v3/tone_chat"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } diff --git a/Scripts/Services/VisualRecognition/V3/VisualRecognitionService.cs b/Scripts/Services/VisualRecognition/V3/VisualRecognitionService.cs index e7d77f02a..e6c9fb8e7 100644 --- a/Scripts/Services/VisualRecognition/V3/VisualRecognitionService.cs +++ b/Scripts/Services/VisualRecognition/V3/VisualRecognitionService.cs @@ -18,6 +18,7 @@ using System.Collections.Generic; using System.Text; using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; using IBM.Cloud.SDK.Connection; using IBM.Cloud.SDK.Utilities; using IBM.Watson.VisualRecognition.V3.Model; @@ -32,20 +33,16 @@ public partial class VisualRecognitionService : BaseService private const string serviceId = "visual_recognition"; private const string defaultUrl = "https://gateway.watsonplatform.net/visual-recognition/api"; - #region Credentials + #region Authenticator /// - /// Gets and sets the credentials of the service. Replace the default endpoint if endpoint is defined. + /// Gets and sets the authenticator of the service. Replace the default endpoint if endpoint is defined. /// - public Credentials Credentials + public Authenticator Authenticator { - get { return credentials; } + get { return authenticator; } set { - credentials = value; - if (!string.IsNullOrEmpty(credentials.Url)) - { - Url = credentials.Url; - } + authenticator = value; } } #endregion @@ -89,17 +86,14 @@ public bool DisableSslVerification /// VisualRecognitionService constructor. /// /// The service version date in `yyyy-mm-dd` format. - public VisualRecognitionService(string versionDate) : base(versionDate, serviceId) - { - VersionDate = versionDate; - } + public VisualRecognitionService(string versionDate) : this(versionDate, ConfigBasedAuthenticatorFactory.GetAuthenticator(serviceId)) {} /// /// VisualRecognitionService constructor. /// /// The service version date in `yyyy-mm-dd` format. - /// The service credentials. - public VisualRecognitionService(string versionDate, Credentials credentials) : base(versionDate, credentials, serviceId) + /// The service authenticator. + public VisualRecognitionService(string versionDate, Authenticator authenticator) : base(versionDate, authenticator, serviceId) { if (string.IsNullOrEmpty(versionDate)) { @@ -110,18 +104,19 @@ public VisualRecognitionService(string versionDate, Credentials credentials) : b VersionDate = versionDate; } - if (credentials.HasCredentials() || credentials.HasTokenData()) + if (authenticator != null) { - Credentials = credentials; + Authenticator = authenticator; - if (string.IsNullOrEmpty(credentials.Url)) + if (string.IsNullOrEmpty(Url)) { - credentials.Url = defaultUrl; + Authenticator.Url = defaultUrl; } + Authenticator.Url = Url; } else { - throw new IBMException("Please provide a username and password or authorization token to use the VisualRecognition service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-credentials"); + throw new IBMException("Please provide a username and password or authorization token to use the VisualRecognition service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-authenticator"); } } @@ -213,11 +208,12 @@ public bool Classify(Callback callback, System.IO.MemoryStream req.OnResponse = OnClassifyResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v3/classify"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v3/classify"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -318,11 +314,12 @@ public bool DetectFaces(Callback callback, System.IO.MemoryStream req.OnResponse = OnDetectFacesResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v3/detect_faces"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v3/detect_faces"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -355,10 +352,16 @@ private void OnDetectFacesResponse(RESTConnector.Request req, RESTConnector.Resp /// Create a classifier. /// /// Train a new multi-faceted classifier on the uploaded image data. Create your custom classifier with positive - /// or negative examples. Include at least two sets of examples, either two positive example files or one - /// positive and one negative file. You can upload a maximum of 256 MB per call. + /// or negative example training images. Include at least two sets of examples, either two positive example + /// files or one positive and one negative file. You can upload a maximum of 256 MB per call. /// - /// Encode all names in UTF-8 if they contain non-ASCII characters (.zip and image file names, and classifier + /// **Tips when creating:** + /// + /// - If you set the **X-Watson-Learning-Opt-Out** header parameter to `true` when you create a classifier, the + /// example training images are not stored. Save your training images locally. For more information, see [Data + /// collection](#data-collection). + /// + /// - Encode all names in UTF-8 if they contain non-ASCII characters (.zip and image file names, and classifier /// and class names). The service assumes UTF-8 encoding if it encounters non-ASCII characters. /// /// The callback function that is invoked when the operation completes. @@ -431,11 +434,12 @@ public bool CreateClassifier(Callback callback, string name, Diction req.OnResponse = OnCreateClassifierResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v3/classifiers"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v3/classifiers"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -503,11 +507,12 @@ public bool ListClassifiers(Callback callback, bool? verbose = null req.OnResponse = OnListClassifiersResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v3/classifiers"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v3/classifiers"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -574,11 +579,12 @@ public bool GetClassifier(Callback callback, string classifierId) req.OnResponse = OnGetClassifierResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v3/classifiers/{0}", classifierId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v3/classifiers/{0}", classifierId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -618,9 +624,15 @@ private void OnGetClassifierResponse(RESTConnector.Request req, RESTConnector.Re /// Encode all names in UTF-8 if they contain non-ASCII characters (.zip and image file names, and classifier /// and class names). The service assumes UTF-8 encoding if it encounters non-ASCII characters. /// - /// **Tip:** Don't make retraining calls on a classifier until the status is ready. When you submit retraining - /// requests in parallel, the last request overwrites the previous requests. The retrained property shows the - /// last time the classifier retraining finished. + /// **Tips about retraining:** + /// + /// - You can't update the classifier if the **X-Watson-Learning-Opt-Out** header parameter was set to `true` + /// when the classifier was created. Training images are not stored in that case. Instead, create another + /// classifier. For more information, see [Data collection](#data-collection). + /// + /// - Don't make retraining calls on a classifier until the status is ready. When you submit retraining requests + /// in parallel, the last request overwrites the previous requests. The `retrained` property shows the last time + /// the classifier retraining finished. /// /// The callback function that is invoked when the operation completes. /// The ID of the classifier. @@ -684,11 +696,12 @@ public bool UpdateClassifier(Callback callback, string classifierId, req.OnResponse = OnUpdateClassifierResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v3/classifiers/{0}", classifierId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v3/classifiers/{0}", classifierId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -753,11 +766,12 @@ public bool DeleteClassifier(Callback callback, string classifierId) req.OnResponse = OnDeleteClassifierResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v3/classifiers/{0}", classifierId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v3/classifiers/{0}", classifierId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -825,11 +839,12 @@ public bool GetCoreMlModel(Callback callback, string classifierId) req.OnResponse = OnGetCoreMlModelResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v3/classifiers/{0}/core_ml_model", classifierId)); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, string.Format("/v3/classifiers/{0}/core_ml_model", classifierId)); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } @@ -895,11 +910,12 @@ public bool DeleteUserData(Callback callback, string customerId) req.OnResponse = OnDeleteUserDataResponse; - RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v3/user_data"); + RESTConnector connector = RESTConnector.GetConnector(Authenticator, "/v3/user_data"); if (connector == null) { return false; } + Authenticator.Authenticate(connector); return connector.Send(req); } From 95d950579375280cd7dc70d7597c19de8c95a3e3 Mon Sep 17 00:00:00 2001 From: Mamoon Raja Date: Thu, 29 Aug 2019 15:23:02 -0400 Subject: [PATCH 2/4] test: update tests and examples to use new authenticator methods --- .gitignore | 2 +- Examples/ExampleAssistantV1.cs | 13 +- Examples/ExampleAssistantV2.cs | 16 +- .../ExampleNaturalLanguageUnderstandingV1.cs | 15 +- Examples/ExamplePersonalityInsightsV3.cs | 13 +- Examples/ExampleStreaming.cs | 17 +- Examples/ExampleToneAnalyzerV3.cs | 16 +- Examples/GenericSerialization.cs | 1 + README.md | 152 ++++-------- .../Services/Assistant/V1/AssistantService.cs | 2 +- .../Assistant/V1/Model/CreateValue.cs | 6 +- .../Services/Assistant/V1/Model/DialogNode.cs | 6 +- .../Assistant/V1/Model/DialogNodeAction.cs | 6 +- .../Assistant/V1/Model/DialogNodeNextStep.cs | 6 +- .../V1/Model/DialogNodeOutputGeneric.cs | 55 +++- .../DialogNodeOutputTextValuesElement.cs | 2 +- .../Assistant/V1/Model/DialogSuggestion.cs | 4 +- .../V1/Model/DialogSuggestionOutput.cs | 54 ++++ .../Model/DialogSuggestionResponseGeneric.cs | 151 +++++++++++ .../V1/Model/DialogSuggestionValue.cs | 4 +- .../Assistant/V1/Model/MessageRequest.cs | 4 +- .../Assistant/V1/Model/MessageResponse.cs | 4 +- .../Services/Assistant/V1/Model/OutputData.cs | 31 ++- .../Assistant/V1/Model/RuntimeEntity.cs | 7 - .../V1/Model/RuntimeEntityInterpretation.cs | 234 ------------------ .../V1/Model/RuntimeResponseGeneric.cs | 157 ++++++++++++ Scripts/Services/Assistant/V1/Model/Value.cs | 6 +- .../Services/Assistant/V2/AssistantService.cs | 2 +- .../Assistant/V2/Model/DialogNodeAction.cs | 6 +- .../Assistant/V2/Model/MessageOutput.cs | 2 +- .../Assistant/V2/Model/RuntimeEntity.cs | 7 - .../V2/Model/RuntimeEntityInterpretation.cs | 234 ------------------ .../V2/Model/RuntimeResponseGeneric.cs | 166 +++++++++++++ .../Assistant/V2/Model/SearchResult.cs | 3 +- .../CompareComply/V1/CompareComplyService.cs | 2 +- .../Services/Discovery/V1/DiscoveryService.cs | 2 +- .../Discovery/V1/Model/CredentialDetails.cs | 24 +- .../Services/Discovery/V1/Model/Enrichment.cs | 2 +- Scripts/Services/Discovery/V1/Model/Field.cs | 8 +- .../V3/LanguageTranslatorService.cs | 2 +- .../V3/Model/DeleteModelResult.cs | 2 +- .../V3/Model/Translation.cs | 2 +- .../V1/NaturalLanguageClassifierService.cs | 2 +- .../V1/Model/SemanticRolesResult.cs | 2 +- .../Model/SemanticRolesResultModelObject.cs | 39 +++ .../V1/NaturalLanguageUnderstandingService.cs | 2 +- .../PersonalityInsights/V3/Model/Warning.cs | 16 +- .../V3/PersonalityInsightsService.cs | 2 +- .../SpeechToText/V1/Model/LanguageModel.cs | 14 +- .../SpeechToText/V1/Model/RecognitionJob.cs | 6 +- .../V1/Model/SpeakerLabelsResult.cs | 2 +- .../V1/Model/SpeechRecognitionAlternative.cs | 10 +- .../V1/Model/SpeechRecognitionResult.cs | 2 +- .../V1/Model/SpeechRecognitionResults.cs | 8 +- .../SpeechToText/V1/Model/TrainingResponse.cs | 36 +++ .../SpeechToText/V1/Model/TrainingWarning.cs | 65 +++++ .../SpeechToText/V1/Model/WordError.cs | 8 +- .../SpeechToText/V1/SpeechToTextService.cs | 2 +- .../V1/SpeechToTextServiceExtension.cs | 11 +- .../TextToSpeech/V1/TextToSpeechService.cs | 2 +- .../ToneAnalyzer/V3/ToneAnalyzerService.cs | 2 +- .../VisualRecognition/V3/Model/ClassResult.cs | 2 +- .../VisualRecognition/V3/Model/FaceGender.cs | 2 +- .../VisualRecognition/V3/Model/ModelClass.cs | 2 +- .../V3/VisualRecognitionService.cs | 2 +- Tests/AssistantV1IntegrationTests.cs | 16 +- Tests/AssistantV2IntegrationTests.cs | 3 +- Tests/CompareComplyV1IntegrationTests.cs | 4 +- Tests/CoreTests.cs | 3 +- Tests/DiscoveryV1IntegrationTests.cs | 10 +- Tests/LanguageTranslatorV3IntegrationTests.cs | 7 +- ...ralLanguageClassifierV1IntegrationTests.cs | 5 +- ...LanguageUnderstandingV1IntegrationTests.cs | 3 +- .../PersonalityInsightsV3IntegrationTests.cs | 3 +- Tests/SpeechToTextV1IntegrationTests.cs | 11 +- Tests/TextToSpeechIntegrationTests.cs | 3 +- Tests/ToneAnalyzerV3IntegrationTests.cs | 3 +- Tests/VisualRecognitionV3IntegrationTests.cs | 5 +- 78 files changed, 969 insertions(+), 794 deletions(-) create mode 100644 Scripts/Services/Assistant/V1/Model/DialogSuggestionOutput.cs create mode 100644 Scripts/Services/Assistant/V1/Model/DialogSuggestionResponseGeneric.cs delete mode 100644 Scripts/Services/Assistant/V1/Model/RuntimeEntityInterpretation.cs create mode 100644 Scripts/Services/Assistant/V1/Model/RuntimeResponseGeneric.cs delete mode 100644 Scripts/Services/Assistant/V2/Model/RuntimeEntityInterpretation.cs create mode 100644 Scripts/Services/Assistant/V2/Model/RuntimeResponseGeneric.cs create mode 100644 Scripts/Services/NaturalLanguageUnderstanding/V1/Model/SemanticRolesResultModelObject.cs create mode 100644 Scripts/Services/SpeechToText/V1/Model/TrainingResponse.cs create mode 100644 Scripts/Services/SpeechToText/V1/Model/TrainingWarning.cs diff --git a/.gitignore b/.gitignore index 9164103cd..1d1ff32bf 100644 --- a/.gitignore +++ b/.gitignore @@ -19,7 +19,7 @@ ExportedObj/ *.user *.unityproj *.booproj - +*.meta # ============ # # OS generated # # ============ # diff --git a/Examples/ExampleAssistantV1.cs b/Examples/ExampleAssistantV1.cs index 17b0ec31b..34a705321 100644 --- a/Examples/ExampleAssistantV1.cs +++ b/Examples/ExampleAssistantV1.cs @@ -20,6 +20,8 @@ using UnityEngine; using IBM.Watson.Assistant.V1; using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; +using IBM.Cloud.SDK.Authentication.Iam; using IBM.Cloud.SDK.Utilities; using IBM.Watson.Assistant.V1.Model; using System; @@ -104,12 +106,15 @@ private void Start() private IEnumerator CreateService() { - service = new AssistantService("2019-02-18"); - // Wait for authorization token - while (!service.Credentials.HasIamTokenData()) + IamAuthenticator authenticator = new IamAuthenticator(apikey: "{iamApikey}"); + + // Wait for tokendata + while (!authenticator.CanAuthenticate()) yield return null; + service = new AssistantService("2019-02-18", authenticator); + workspaceId = Environment.GetEnvironmentVariable("CONVERSATION_WORKSPACE_ID"); Runnable.Run(Examples()); } @@ -118,7 +123,7 @@ private IEnumerator Examples() { // List Workspaces Log.Debug("ExampleAssistantV1", "Attempting to ListWorkspaces..."); - service.ListWorkspaces(callback: OnListWorkspaces, pageLimit: 1, includeCount: true, sort: "-name", includeAudit: true); + service.ListWorkspaces(callback: OnListWorkspaces, pageLimit: 1, sort: "-name", includeAudit: true); while (!listWorkspacesTested) yield return null; diff --git a/Examples/ExampleAssistantV2.cs b/Examples/ExampleAssistantV2.cs index 277a62d22..e92c0984c 100644 --- a/Examples/ExampleAssistantV2.cs +++ b/Examples/ExampleAssistantV2.cs @@ -18,6 +18,8 @@ using System.Collections; using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; +using IBM.Cloud.SDK.Authentication.Iam; using IBM.Cloud.SDK.Utilities; using IBM.Watson.Assistant.V2; using IBM.Watson.Assistant.V2.Model; @@ -68,21 +70,13 @@ private IEnumerator CreateService() } // Create credential and instantiate service - Credentials credentials = null; - - // Authenticate using iamApikey - TokenOptions tokenOptions = new TokenOptions() - { - IamApiKey = iamApikey - }; - - credentials = new Credentials(tokenOptions, serviceUrl); + IamAuthenticator authenticator = new IamAuthenticator(apikey: iamApikey); // Wait for tokendata - while (!credentials.HasIamTokenData()) + while (!authenticator.CanAuthenticate()) yield return null; - service = new AssistantService(versionDate, credentials); + service = new AssistantService(versionDate, authenticator); Runnable.Run(Examples()); } diff --git a/Examples/ExampleNaturalLanguageUnderstandingV1.cs b/Examples/ExampleNaturalLanguageUnderstandingV1.cs index 53d49dfb1..3fe808dbc 100644 --- a/Examples/ExampleNaturalLanguageUnderstandingV1.cs +++ b/Examples/ExampleNaturalLanguageUnderstandingV1.cs @@ -19,6 +19,7 @@ using IBM.Watson.NaturalLanguageUnderstanding.V1.Model; using IBM.Cloud.SDK.Utilities; using IBM.Cloud.SDK.Authentication; +using IBM.Cloud.SDK.Authentication.Iam; using System.Collections; using System.Collections.Generic; using UnityEngine; @@ -57,18 +58,18 @@ private IEnumerator CreateService() throw new IBMException("Please add IAM ApiKey to the Iam Apikey field in the inspector."); } - IamTokenOptions tokenOptions = new IamTokenOptions() - { - IamApiKey = iamApikey - }; - Credentials credentials = new Credentials(tokenOptions, serviceUrl); + IamAuthenticator authenticator = new IamAuthenticator(apikey: iamApikey); + + // Wait for tokendata + while (!authenticator.CanAuthenticate()) + yield return null; - while (!credentials.HasTokenData()) + while (!authenticator.CanAuthenticate()) { yield return null; } - service = new NaturalLanguageUnderstandingService(versionDate, credentials); + service = new NaturalLanguageUnderstandingService(versionDate, authenticator); Runnable.Run(ExampleAnalyze()); Runnable.Run(ExampleListModels()); diff --git a/Examples/ExamplePersonalityInsightsV3.cs b/Examples/ExamplePersonalityInsightsV3.cs index 31fd8fda4..339c894a4 100644 --- a/Examples/ExamplePersonalityInsightsV3.cs +++ b/Examples/ExamplePersonalityInsightsV3.cs @@ -16,6 +16,8 @@ */ using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; +using IBM.Cloud.SDK.Authentication.Iam; using IBM.Cloud.SDK.Utilities; using IBM.Watson.PersonalityInsights.V3; using IBM.Watson.PersonalityInsights.V3.Model; @@ -35,7 +37,7 @@ public class ExamplePersonalityInsightsV3 : MonoBehaviour private bool profileTested = false; private bool profileAsCsvTested = false; - + private void Start() { LogSystem.InstallDefaultReactors(); @@ -45,12 +47,15 @@ private void Start() private IEnumerator CreateService() { - service = new PersonalityInsightsService("2019-02-18"); - // Wait for authorization token - while (!service.Credentials.HasIamTokenData()) + IamAuthenticator authenticator = new IamAuthenticator(apikey: "{iamApikey}"); + + // Wait for tokendata + while (!authenticator.CanAuthenticate()) yield return null; + service = new PersonalityInsightsService("2019-02-18", authenticator); + Runnable.Run(Examples()); } diff --git a/Examples/ExampleStreaming.cs b/Examples/ExampleStreaming.cs index 2c4d1a97e..cb6ed6fb5 100644 --- a/Examples/ExampleStreaming.cs +++ b/Examples/ExampleStreaming.cs @@ -22,6 +22,8 @@ using UnityEngine.UI; using IBM.Watson.SpeechToText.V1; using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; +using IBM.Cloud.SDK.Authentication.Iam; using IBM.Cloud.SDK.Utilities; using IBM.Cloud.SDK.DataTypes; @@ -70,22 +72,13 @@ private IEnumerator CreateService() throw new IBMException("Plesae provide IAM ApiKey for the service."); } - // Create credential and instantiate service - Credentials credentials = null; - - // Authenticate using iamApikey - TokenOptions tokenOptions = new TokenOptions() - { - IamApiKey = _iamApikey - }; - - credentials = new Credentials(tokenOptions, _serviceUrl); + IamAuthenticator authenticator = new IamAuthenticator(apikey: _iamApikey); // Wait for tokendata - while (!credentials.HasIamTokenData()) + while (!authenticator.CanAuthenticate()) yield return null; - _service = new SpeechToTextService(credentials); + _service = new SpeechToTextService(authenticator); _service.StreamMultipart = true; Active = true; diff --git a/Examples/ExampleToneAnalyzerV3.cs b/Examples/ExampleToneAnalyzerV3.cs index 54d7e487f..7a266669c 100644 --- a/Examples/ExampleToneAnalyzerV3.cs +++ b/Examples/ExampleToneAnalyzerV3.cs @@ -22,6 +22,8 @@ using System.Collections.Generic; using UnityEngine; using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; +using IBM.Cloud.SDK.Authentication.Iam; namespace IBM.Watson.Examples { @@ -60,21 +62,13 @@ private IEnumerator CreateService() } // Create credential and instantiate service - Credentials credentials = null; - - // Authenticate using iamApikey - TokenOptions tokenOptions = new TokenOptions() - { - IamApiKey = iamApikey - }; - - credentials = new Credentials(tokenOptions, serviceUrl); + IamAuthenticator authenticator = new IamAuthenticator(apikey: iamApikey); // Wait for tokendata - while (!credentials.HasIamTokenData()) + while (!authenticator.CanAuthenticate()) yield return null; - service = new ToneAnalyzerService(versionDate, credentials); + service = new ToneAnalyzerService(versionDate, authenticator); Runnable.Run(Examples()); } diff --git a/Examples/GenericSerialization.cs b/Examples/GenericSerialization.cs index aa832e3c9..2d1af04ba 100644 --- a/Examples/GenericSerialization.cs +++ b/Examples/GenericSerialization.cs @@ -18,6 +18,7 @@ using System.Collections.Generic; using UnityEngine; using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; using Newtonsoft.Json; using IBM.Watson.Assistant.V2.Model; diff --git a/README.md b/README.md index ab1950ea6..2ee1e8d38 100755 --- a/README.md +++ b/README.md @@ -107,29 +107,18 @@ You supply either an IAM service **API key** or an **access token**: #### Supplying the IAM API key ```cs -Credentials credentials; +Authenticator authenticator; AssistantService assistant; string versionDate = ""; IEnumerator TokenExample() { - // Create IAM token options and supply the apikey. IamUrl is the URL used to get the - // authorization token using the IamApiKey. It defaults to https://iam.cloud.ibm.com/identity/token - TokenOptions iamTokenOptions = new TokenOptions() - { - IamApiKey = "", - IamUrl = "" - }; - - // Create credentials using the IAM token options - credentials = new Credentials(iamTokenOptions, ""); - while (!credentials.HasIamTokenData()) + // Create authenticator using the IAM token options + authenticator = new IamAuthenticator(apikey: ""); + while (!authenticator.CanAuthenticate()) yield return null; - assistant = new AssistantService( - versionDate: versionDate, - credentials: credentials - ); + assistant = new AssistantService(versionDate, authenticator); assistant.ListWorkspaces(callback: OnListWorkspaces); } @@ -141,25 +130,16 @@ private void OnListWorkspaces(DetailedResponse response, IB #### Supplying the access token ```cs -Credentials credentials; +Authenticator authenticator; AssistantService assistant; string versionDate = ""; void TokenExample() { - // Create IAM token options and supply the access token. - TokenOptions iamTokenOptions = new TokenOptions() - { - IamAccessToken = "" - }; - - // Create credentials using the IAM token options - credentials = new Credentials(iamTokenOptions, ""); + // Create authenticator using the IAM apikey + authenticator = new IamAuthenticator(apikey: ""); - assistant = new AssistantService( - versionDate: versionDate, - credentials: credentials - ); + assistant = new AssistantService(versionDate, authenticator); assistant.ListWorkspaces(callback: OnListWorkspaces); } @@ -171,23 +151,20 @@ private void OnListWorkspaces(DetailedResponse response, IB ### Username and password ```cs -Credentials credentials; +Authenticator authenticator; AssistantService assistant; string versionDate = ""; void UsernamePasswordExample() { - Credentials credentials = new Credentials("", "", ""); - assistant = new AssistantService( - versionDate: versionDate, - credentials: credentials - ); + Authenticator authenticator = new BasicAuthenticator("", "", ""); + assistant = new AssistantService(versionDate, authenticator); } ``` -### Supplying credentials +### Supplying authenticator -There are two ways to supply the credentials you found above to the SDK for authentication. +There are two ways to supply the authenticator you found above to the SDK for authentication. #### Credential file (easier!) @@ -206,16 +183,16 @@ public IEnumerator ExampleAutoService() Assistant assistantService = new Assistant("2019-04-03"); // Wait for authorization token - while (!assistantService.Credentials.HasIamTokenData()) + while (!assistantService.Authenticator.CanAuthenticate()) yield return null; - + var listWorkspacesResult = assistantService.ListWorkspaces(); } ``` And that's it! -If you're using more than one service at a time in your code and get two different `ibm-credentials.env` files, just put the contents together in one `ibm-credentials.env` file and the SDK will handle assigning credentials to their appropriate services. +If you're using more than one service at a time in your code and get two different `ibm-authenticator.env` files, just put the contents together in one `ibm-authenticator.env` file and the SDK will handle assigning authenticator to their appropriate services. If you would like to configure the location/name of your credential file, you can set an environment variable called `IBM_CREDENTIALS_FILE`. **This will take precedence over the locations specified above.** Here's how you can do that: @@ -227,35 +204,29 @@ where `` is something like `/home/user/Downloads/.env`. #### Manually -If you'd prefer to set authentication values manually in your code, the SDK supports that as well. The way you'll do this depends on what type of credentials your service instance gives you. +If you'd prefer to set authentication values manually in your code, the SDK supports that as well. The way you'll do this depends on what type of authenticator your service instance gives you. ## Callbacks -A success callback is required. You can specify the return type in the callback. +A success callback is required. You can specify the return type in the callback. ```cs AssistantService assistant; string assistantVersionDate = ""; -Credentials assistantCredentials; +Authenticator assistantAuthenticator; string workspaceId = ""; DiscoveryService discovery; string discoveryVersionDate = ""; -Credentials discoveryCredentials; +Authenticator discoveryAuthenticator; private void Example() { - assistant = new AssistantService( - versionDate: assistantVersionDate, - credentials: assistantCredentials - ); + assistant = new AssistantService(assistantVersionDate, assistantAuthenticator); - discovery = new DiscoveryService( - versionDate: discoveryVersionDate, - credentials: discoveryCredentials - ); + discovery = new DiscoveryService(discoveryVersionDate, discoveryAuthenticator); // Call with sepcific callbacks assistant.Message( - callback: OnMessage, + callback: OnMessage, workspaceId: workspaceId ); @@ -279,25 +250,22 @@ Since the success callback signature is generic and the failure callback always ```cs AssistantService assistant; string assistantVersionDate = ""; -Credentials assistantCredentials; +Authenticator assistantAuthenticator; string workspaceId = ""; DiscoveryService discovery; string discoveryVersionDate = ""; -Credentials discoveryCredentials; +Authenticator discoveryAuthenticator; private void Example() { - assistant = new AssistantService( - versionDate: assistantVersionDate, - credentials: assistantCredentials - ); + assistant = new AssistantService(assistantVersionDate, assistantAuthenticator); // Call with generic callbacks JObject input = new JObject(); input.Add("text", ""); assistant.Message( - callback: OnSuccess, + callback: OnSuccess, workspaceId: workspaceId, input: input ); @@ -318,15 +286,12 @@ You can also use an anonymous callback ```cs AssistantService assistant; string assistantVersionDate = ""; -Credentials assistantCredentials; +Authenticator assistantAuthenticator; string workspaceId = ""; private void Example() { - assistant = new AssistantService( - versionDate: assistantVersionDate, - credentials: assistantCredentials - ); + assistant = new AssistantService(assistantVersionDate, assistantAuthenticator); assistant.ListWorkspaces( callback: (DetailedResponse response, IBMError error) => @@ -345,15 +310,12 @@ You can check the `error` response to see if there was an error in the call. ```cs AssistantService assistant; string assistantVersionDate = ""; -Credentials assistantCredentials; +Authenticator assistantAuthenticator; string workspaceId = ""; private void Example() { - assistant = new AssistantService( - versionDate: assistantVersionDate, - credentials: assistantCredentials - ); + assistant = new AssistantService(versionDate, authenticator); assistant.Message(OnMessage, workspaceId); } @@ -377,15 +339,12 @@ You can send custom request headers by adding them to the service. ```cs AssistantService assistant; string assistantVersionDate = ""; -Credentials assistantCredentials; +Authenticator assistantAuthenticator; string workspaceId = ""; void Example() { - assistant = new AssistantService( - versionDate: assistantVersionDate, - credentials: assistantCredentials - ); + assistant = new AssistantService(assistantVersionDate, assistantAuthenticator); // Add custom header to the REST call assistant.WithHeader("X-Watson-Metadata", "customer_id=some-assistant-customer-id"); @@ -404,15 +363,12 @@ You can get response headers in the `headers` object in the DetailedResponse. ```cs AssistantService assistant; string assistantVersionDate = ""; -Credentials assistantCredentials; +Authenticator assistantAuthenticator; string workspaceId = ""; void Example() { - assistant = new AssistantService( - versionDate: assistantVersionDate, - credentials: assistantCredentials - ); + assistant = new AssistantService(assistantVersionDate, assistantAuthenticator); assistant.Message(OnMessage, ""); } @@ -435,16 +391,13 @@ You can disable SSL verifciation when making a service call. ```cs AssistantService assistant; string assistantVersionDate = ""; -Credentials assistantCredentials; +Authenticator assistantAuthenticator; string workspaceId = ""; void Example() { - credentials.DisableSslVerification = true; - assistant = new AssistantService( - versionDate: assistantVersionDate, - credentials: assistantCredentials - ); + authenticator.DisableSslVerification = true; + assistant = new AssistantService(assistantVersionDate, assistantAuthenticator); // disable ssl verification assistant.DisableSslVerification = true; @@ -459,38 +412,23 @@ If your service instance is of ICP4D, below are two ways of initializing the ass The SDK will manage the token for the user ```cs - Icp4dTokenOptions tokenOptions = new Icp4dTokenOptions() - { - Username = "", - Password = "", - Url = "", - DisableSslVerification = true - }; - credentials = new Credentials(tokenOptions, ""); - while(!credentials.HasTokenData()) + CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator("", "", ""); + while(!authenticator.CanAuthenticate()) { yield return null; } - service = new AssistantService(versionDate, credentials); + service = new AssistantService(versionDate, authenticator); ``` #### 2) Supplying the access token ```cs - Icp4dTokenOptions tokenOptions = new Icp4dTokenOptions() - { - Username = "", - Password = "", - Url = "", - AccessToken = "", - DisableSslVerification = true - }; - credentials = new Credentials(tokenOptions, ""); - while(!credentials.HasTokenData()) + BearerTokenAuthenticator = new BearerTokenAuthenticator(""); + while(!authenticator.CanAuthenticate()) { yield return null; } - service = new AssistantService(versionDate, credentials); + service = new AssistantService(versionDate, authenticator); ``` ## IBM Cloud Private diff --git a/Scripts/Services/Assistant/V1/AssistantService.cs b/Scripts/Services/Assistant/V1/AssistantService.cs index 01cabb8aa..d7846ae21 100644 --- a/Scripts/Services/Assistant/V1/AssistantService.cs +++ b/Scripts/Services/Assistant/V1/AssistantService.cs @@ -117,7 +117,7 @@ public AssistantService(string versionDate, Authenticator authenticator) : base( } else { - 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"); + 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"); } } diff --git a/Scripts/Services/Assistant/V1/Model/CreateValue.cs b/Scripts/Services/Assistant/V1/Model/CreateValue.cs index e1f68a0bd..da779b100 100644 --- a/Scripts/Services/Assistant/V1/Model/CreateValue.cs +++ b/Scripts/Services/Assistant/V1/Model/CreateValue.cs @@ -29,7 +29,7 @@ public class CreateValue /// /// Specifies the type of entity value. /// - public class ValueTypeValue + public class TypeValue { /// /// Constant SYNONYMS for synonyms @@ -44,10 +44,10 @@ public class ValueTypeValue /// /// Specifies the type of entity value. - /// Constants for possible values can be found using CreateValue.ValueTypeValue + /// Constants for possible values can be found using CreateValue.TypeValue /// [JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)] - public string ValueType { get; set; } + public string Type { get; set; } /// /// The text of the entity value. This string must conform to the following restrictions: /// - It cannot contain carriage return, newline, or tab characters. diff --git a/Scripts/Services/Assistant/V1/Model/DialogNode.cs b/Scripts/Services/Assistant/V1/Model/DialogNode.cs index d5e7b7e06..2dcc1188d 100644 --- a/Scripts/Services/Assistant/V1/Model/DialogNode.cs +++ b/Scripts/Services/Assistant/V1/Model/DialogNode.cs @@ -30,7 +30,7 @@ public class DialogNode /// /// How the dialog node is processed. /// - public class NodeTypeValue + public class TypeValue { /// /// Constant STANDARD for standard @@ -165,10 +165,10 @@ public class DigressOutSlotsValue /// /// How the dialog node is processed. - /// Constants for possible values can be found using DialogNode.NodeTypeValue + /// Constants for possible values can be found using DialogNode.TypeValue /// [JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)] - public string NodeType { get; set; } + public string Type { get; set; } /// /// How an `event_handler` node is processed. /// Constants for possible values can be found using DialogNode.EventNameValue diff --git a/Scripts/Services/Assistant/V1/Model/DialogNodeAction.cs b/Scripts/Services/Assistant/V1/Model/DialogNodeAction.cs index cce7476c0..825b10250 100644 --- a/Scripts/Services/Assistant/V1/Model/DialogNodeAction.cs +++ b/Scripts/Services/Assistant/V1/Model/DialogNodeAction.cs @@ -28,7 +28,7 @@ public class DialogNodeAction /// /// The type of action to invoke. /// - public class ActionTypeValue + public class TypeValue { /// /// Constant CLIENT for client @@ -51,10 +51,10 @@ public class ActionTypeValue /// /// The type of action to invoke. - /// Constants for possible values can be found using DialogNodeAction.ActionTypeValue + /// Constants for possible values can be found using DialogNodeAction.TypeValue /// [JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)] - public string ActionType { get; set; } + public string Type { get; set; } /// /// The name of the action. /// diff --git a/Scripts/Services/Assistant/V1/Model/DialogNodeNextStep.cs b/Scripts/Services/Assistant/V1/Model/DialogNodeNextStep.cs index a0734d708..5e8a9f9ac 100644 --- a/Scripts/Services/Assistant/V1/Model/DialogNodeNextStep.cs +++ b/Scripts/Services/Assistant/V1/Model/DialogNodeNextStep.cs @@ -43,8 +43,7 @@ public class DialogNodeNextStep /// - `reprompt` /// - `skip_slot` /// - `skip_all_slots` - /// - /// If you specify `jump_to`, then you must also specify a value for the `dialog_node` property. + /// If you specify `jump_to`, then you must also specify a value for the `dialog_node` property. /// public class BehaviorValue { @@ -118,8 +117,7 @@ public class SelectorValue /// - `reprompt` /// - `skip_slot` /// - `skip_all_slots` - /// - /// If you specify `jump_to`, then you must also specify a value for the `dialog_node` property. + /// If you specify `jump_to`, then you must also specify a value for the `dialog_node` property. /// Constants for possible values can be found using DialogNodeNextStep.BehaviorValue /// [JsonProperty("behavior", NullValueHandling = NullValueHandling.Ignore)] diff --git a/Scripts/Services/Assistant/V1/Model/DialogNodeOutputGeneric.cs b/Scripts/Services/Assistant/V1/Model/DialogNodeOutputGeneric.cs index 052638028..030389720 100644 --- a/Scripts/Services/Assistant/V1/Model/DialogNodeOutputGeneric.cs +++ b/Scripts/Services/Assistant/V1/Model/DialogNodeOutputGeneric.cs @@ -28,6 +28,9 @@ public class DialogNodeOutputGeneric /// /// The type of response returned by the dialog node. The specified response type must be supported by the /// client application or channel. + /// + /// **Note:** The **search_skill** response type is available only for Plus and Premium users, and is used only + /// by the v2 runtime API. /// public class ResponseTypeValue { @@ -51,6 +54,10 @@ public class ResponseTypeValue /// Constant CONNECT_TO_AGENT for connect_to_agent /// public const string CONNECT_TO_AGENT = "connect_to_agent"; + /// + /// Constant SEARCH_SKILL for search_skill + /// + public const string SEARCH_SKILL = "search_skill"; } @@ -92,9 +99,28 @@ public class PreferenceValue } + /// + /// The type of the search query. Required when **response_type**=`search_skill`. + /// + public class QueryTypeValue + { + /// + /// Constant NATURAL_LANGUAGE for natural_language + /// + public const string NATURAL_LANGUAGE = "natural_language"; + /// + /// Constant DISCOVERY_QUERY_LANGUAGE for discovery_query_language + /// + public const string DISCOVERY_QUERY_LANGUAGE = "discovery_query_language"; + + } + /// /// The type of response returned by the dialog node. The specified response type must be supported by the /// client application or channel. + /// + /// **Note:** The **search_skill** response type is available only for Plus and Premium users, and is used only + /// by the v2 runtime API. /// Constants for possible values can be found using DialogNodeOutputGeneric.ResponseTypeValue /// [JsonProperty("response_type", NullValueHandling = NullValueHandling.Ignore)] @@ -114,6 +140,12 @@ public class PreferenceValue [JsonProperty("preference", NullValueHandling = NullValueHandling.Ignore)] public string Preference { get; set; } /// + /// The type of the search query. Required when **response_type**=`search_skill`. + /// Constants for possible values can be found using DialogNodeOutputGeneric.QueryTypeValue + /// + [JsonProperty("query_type", NullValueHandling = NullValueHandling.Ignore)] + public string QueryType { get; set; } + /// /// A list of one or more objects defining text responses. Required when **response_type**=`text`. /// [JsonProperty("values", NullValueHandling = NullValueHandling.Ignore)] @@ -130,7 +162,7 @@ public class PreferenceValue [JsonProperty("time", NullValueHandling = NullValueHandling.Ignore)] public long? Time { get; set; } /// - /// Whether to send a \"user is typing\" event during the pause. Ignored if the channel does not support this + /// Whether to send a "user is typing" event during the pause. Ignored if the channel does not support this /// event. Valid only when **response_type**=`pause`. /// [JsonProperty("typing", NullValueHandling = NullValueHandling.Ignore)] @@ -162,5 +194,26 @@ public class PreferenceValue /// [JsonProperty("message_to_human_agent", NullValueHandling = NullValueHandling.Ignore)] public string MessageToHumanAgent { get; set; } + /// + /// The text of the search query. This can be either a natural-language query or a query that uses the Discovery + /// query language syntax, depending on the value of the **query_type** property. For more information, see the + /// [Discovery service + /// documentation](https://cloud.ibm.com/docs/services/discovery/query-operators.html#query-operators). Required + /// when **response_type**=`search_skill`. + /// + [JsonProperty("query", NullValueHandling = NullValueHandling.Ignore)] + public string Query { get; set; } + /// + /// An optional filter that narrows the set of documents to be searched. For more information, see the + /// [Discovery service documentation]([Discovery service + /// documentation](https://cloud.ibm.com/docs/services/discovery/query-parameters.html#filter). + /// + [JsonProperty("filter", NullValueHandling = NullValueHandling.Ignore)] + public string Filter { get; set; } + /// + /// The version of the Discovery service API to use for the query. + /// + [JsonProperty("discovery_version", NullValueHandling = NullValueHandling.Ignore)] + public string DiscoveryVersion { get; set; } } } diff --git a/Scripts/Services/Assistant/V1/Model/DialogNodeOutputTextValuesElement.cs b/Scripts/Services/Assistant/V1/Model/DialogNodeOutputTextValuesElement.cs index ae73839fc..0d2b810a4 100644 --- a/Scripts/Services/Assistant/V1/Model/DialogNodeOutputTextValuesElement.cs +++ b/Scripts/Services/Assistant/V1/Model/DialogNodeOutputTextValuesElement.cs @@ -25,7 +25,7 @@ namespace IBM.Watson.Assistant.V1.Model public class DialogNodeOutputTextValuesElement { /// - /// The text of a response. This string can include newline characters (`\\n`), Markdown tagging, or other + /// The text of a response. This string can include newline characters (`\n`), Markdown tagging, or other /// special characters, if supported by the channel. /// [JsonProperty("text", NullValueHandling = NullValueHandling.Ignore)] diff --git a/Scripts/Services/Assistant/V1/Model/DialogSuggestion.cs b/Scripts/Services/Assistant/V1/Model/DialogSuggestion.cs index 934b63e7d..8e0e73b2f 100644 --- a/Scripts/Services/Assistant/V1/Model/DialogSuggestion.cs +++ b/Scripts/Services/Assistant/V1/Model/DialogSuggestion.cs @@ -15,8 +15,8 @@ * */ -using System.Collections.Generic; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; namespace IBM.Watson.Assistant.V1.Model { @@ -42,7 +42,7 @@ public class DialogSuggestion /// corresponding option. /// [JsonProperty("output", NullValueHandling = NullValueHandling.Ignore)] - public Dictionary Output { get; set; } + public JObject Output { get; set; } /// /// The ID of the dialog node that the **label** property is taken from. The **label** property is populated /// using the value of the dialog node's **user_label** property. diff --git a/Scripts/Services/Assistant/V1/Model/DialogSuggestionOutput.cs b/Scripts/Services/Assistant/V1/Model/DialogSuggestionOutput.cs new file mode 100644 index 000000000..7b0b7a45e --- /dev/null +++ b/Scripts/Services/Assistant/V1/Model/DialogSuggestionOutput.cs @@ -0,0 +1,54 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace IBM.Watson.Assistant.V1.Model +{ + /// + /// The dialog output that will be returned from the Watson Assistant service if the user selects the corresponding + /// option. + /// + public class DialogSuggestionOutput + { + /// + /// An array of the nodes that were triggered to create the response, in the order in which they were visited. + /// This information is useful for debugging and for tracing the path taken through the node tree. + /// + [JsonProperty("nodes_visited", NullValueHandling = NullValueHandling.Ignore)] + public List NodesVisited { get; set; } + /// + /// An array of objects containing detailed diagnostic information about the nodes that were triggered during + /// processing of the input message. Included only if **nodes_visited_details** is set to `true` in the message + /// request. + /// + [JsonProperty("nodes_visited_details", NullValueHandling = NullValueHandling.Ignore)] + public List NodesVisitedDetails { get; set; } + /// + /// An array of responses to the user. + /// + [JsonProperty("text", NullValueHandling = NullValueHandling.Ignore)] + public List Text { get; set; } + /// + /// Output intended for any channel. It is the responsibility of the client application to implement the + /// supported response types. + /// + [JsonProperty("generic", NullValueHandling = NullValueHandling.Ignore)] + public List Generic { get; set; } + } +} diff --git a/Scripts/Services/Assistant/V1/Model/DialogSuggestionResponseGeneric.cs b/Scripts/Services/Assistant/V1/Model/DialogSuggestionResponseGeneric.cs new file mode 100644 index 000000000..9e0fe1690 --- /dev/null +++ b/Scripts/Services/Assistant/V1/Model/DialogSuggestionResponseGeneric.cs @@ -0,0 +1,151 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace IBM.Watson.Assistant.V1.Model +{ + /// + /// DialogSuggestionResponseGeneric. + /// + public class DialogSuggestionResponseGeneric + { + /// + /// The type of response returned by the dialog node. The specified response type must be supported by the + /// client application or channel. + /// + /// **Note:** The **suggestion** response type is part of the disambiguation feature, which is only available + /// for Plus and Premium users. The **search_skill** response type is available only for Plus and Premium users, + /// and is used only by the v2 runtime API. + /// + public class ResponseTypeValue + { + /// + /// Constant TEXT for text + /// + public const string TEXT = "text"; + /// + /// Constant PAUSE for pause + /// + public const string PAUSE = "pause"; + /// + /// Constant IMAGE for image + /// + public const string IMAGE = "image"; + /// + /// Constant OPTION for option + /// + public const string OPTION = "option"; + /// + /// Constant CONNECT_TO_AGENT for connect_to_agent + /// + public const string CONNECT_TO_AGENT = "connect_to_agent"; + /// + /// Constant SEARCH_SKILL for search_skill + /// + public const string SEARCH_SKILL = "search_skill"; + + } + + /// + /// The preferred type of control to display. + /// + public class PreferenceValue + { + /// + /// Constant DROPDOWN for dropdown + /// + public const string DROPDOWN = "dropdown"; + /// + /// Constant BUTTON for button + /// + public const string BUTTON = "button"; + + } + + /// + /// The type of response returned by the dialog node. The specified response type must be supported by the + /// client application or channel. + /// + /// **Note:** The **suggestion** response type is part of the disambiguation feature, which is only available + /// for Plus and Premium users. The **search_skill** response type is available only for Plus and Premium users, + /// and is used only by the v2 runtime API. + /// Constants for possible values can be found using DialogSuggestionResponseGeneric.ResponseTypeValue + /// + [JsonProperty("response_type", NullValueHandling = NullValueHandling.Ignore)] + public string ResponseType { get; set; } + /// + /// The preferred type of control to display. + /// Constants for possible values can be found using DialogSuggestionResponseGeneric.PreferenceValue + /// + [JsonProperty("preference", NullValueHandling = NullValueHandling.Ignore)] + public string Preference { get; set; } + /// + /// The text of the response. + /// + [JsonProperty("text", NullValueHandling = NullValueHandling.Ignore)] + public string Text { get; set; } + /// + /// How long to pause, in milliseconds. + /// + [JsonProperty("time", NullValueHandling = NullValueHandling.Ignore)] + public long? Time { get; set; } + /// + /// Whether to send a "user is typing" event during the pause. + /// + [JsonProperty("typing", NullValueHandling = NullValueHandling.Ignore)] + public bool? Typing { get; set; } + /// + /// The URL of the image. + /// + [JsonProperty("source", NullValueHandling = NullValueHandling.Ignore)] + public string Source { get; set; } + /// + /// The title or introductory text to show before the response. + /// + [JsonProperty("title", NullValueHandling = NullValueHandling.Ignore)] + public string Title { get; set; } + /// + /// The description to show with the the response. + /// + [JsonProperty("description", NullValueHandling = NullValueHandling.Ignore)] + public string Description { get; set; } + /// + /// An array of objects describing the options from which the user can choose. + /// + [JsonProperty("options", NullValueHandling = NullValueHandling.Ignore)] + public List Options { get; set; } + /// + /// A message to be sent to the human agent who will be taking over the conversation. + /// + [JsonProperty("message_to_human_agent", NullValueHandling = NullValueHandling.Ignore)] + public string MessageToHumanAgent { get; set; } + /// + /// A label identifying the topic of the conversation, derived from the **user_label** property of the relevant + /// node. + /// + [JsonProperty("topic", NullValueHandling = NullValueHandling.Ignore)] + public virtual string Topic { get; private set; } + /// + /// The ID of the dialog node that the **topic** property is taken from. The **topic** property is populated + /// using the value of the dialog node's **user_label** property. + /// + [JsonProperty("dialog_node", NullValueHandling = NullValueHandling.Ignore)] + public string DialogNode { get; set; } + } +} diff --git a/Scripts/Services/Assistant/V1/Model/DialogSuggestionValue.cs b/Scripts/Services/Assistant/V1/Model/DialogSuggestionValue.cs index 3ec321e84..6bc123bef 100644 --- a/Scripts/Services/Assistant/V1/Model/DialogSuggestionValue.cs +++ b/Scripts/Services/Assistant/V1/Model/DialogSuggestionValue.cs @@ -36,11 +36,11 @@ public class DialogSuggestionValue /// An array of intents to be sent along with the user input. /// [JsonProperty("intents", NullValueHandling = NullValueHandling.Ignore)] - public List Intents { get; set; } + public List Intents { get; set; } /// /// An array of entities to be sent along with the user input. /// [JsonProperty("entities", NullValueHandling = NullValueHandling.Ignore)] - public List Entities { get; set; } + public List Entities { get; set; } } } diff --git a/Scripts/Services/Assistant/V1/Model/MessageRequest.cs b/Scripts/Services/Assistant/V1/Model/MessageRequest.cs index 808808eb8..8b2597a9d 100644 --- a/Scripts/Services/Assistant/V1/Model/MessageRequest.cs +++ b/Scripts/Services/Assistant/V1/Model/MessageRequest.cs @@ -36,13 +36,13 @@ public class MessageRequest /// those intents rather than trying to recognize intents in the new input. /// [JsonProperty("intents", NullValueHandling = NullValueHandling.Ignore)] - public List Intents { get; set; } + public List Intents { get; set; } /// /// Entities to use when evaluating the message. Include entities from the previous response to continue using /// those entities rather than detecting entities in the new input. /// [JsonProperty("entities", NullValueHandling = NullValueHandling.Ignore)] - public List Entities { get; set; } + public List Entities { get; set; } /// /// Whether to return more than one intent. A value of `true` indicates that all matching intents are returned. /// diff --git a/Scripts/Services/Assistant/V1/Model/MessageResponse.cs b/Scripts/Services/Assistant/V1/Model/MessageResponse.cs index 6bbc2f2d1..ed3d4e01d 100644 --- a/Scripts/Services/Assistant/V1/Model/MessageResponse.cs +++ b/Scripts/Services/Assistant/V1/Model/MessageResponse.cs @@ -35,12 +35,12 @@ public class MessageResponse /// An array of intents recognized in the user input, sorted in descending order of confidence. /// [JsonProperty("intents", NullValueHandling = NullValueHandling.Ignore)] - public List Intents { get; set; } + public List Intents { get; set; } /// /// An array of entities identified in the user input. /// [JsonProperty("entities", NullValueHandling = NullValueHandling.Ignore)] - public List Entities { get; set; } + public List Entities { get; set; } /// /// Whether to return more than one intent. A value of `true` indicates that all matching intents are returned. /// diff --git a/Scripts/Services/Assistant/V1/Model/OutputData.cs b/Scripts/Services/Assistant/V1/Model/OutputData.cs index 9f9f77ec0..b443e8fb0 100644 --- a/Scripts/Services/Assistant/V1/Model/OutputData.cs +++ b/Scripts/Services/Assistant/V1/Model/OutputData.cs @@ -17,7 +17,6 @@ using System.Collections.Generic; using Newtonsoft.Json; -using Newtonsoft.Json.Linq; namespace IBM.Watson.Assistant.V1.Model { @@ -27,11 +26,24 @@ namespace IBM.Watson.Assistant.V1.Model /// public class OutputData { + /// + /// An array of the nodes that were triggered to create the response, in the order in which they were visited. + /// This information is useful for debugging and for tracing the path taken through the node tree. + /// + [JsonProperty("nodes_visited", NullValueHandling = NullValueHandling.Ignore)] + public List NodesVisited { get; set; } + /// + /// An array of objects containing detailed diagnostic information about the nodes that were triggered during + /// processing of the input message. Included only if **nodes_visited_details** is set to `true` in the message + /// request. + /// + [JsonProperty("nodes_visited_details", NullValueHandling = NullValueHandling.Ignore)] + public List NodesVisitedDetails { get; set; } /// /// An array of up to 50 messages logged with the request. /// [JsonProperty("log_messages", NullValueHandling = NullValueHandling.Ignore)] - public List LogMessages { get; set; } + public List LogMessages { get; set; } /// /// An array of responses to the user. /// @@ -42,19 +54,6 @@ public class OutputData /// supported response types. /// [JsonProperty("generic", NullValueHandling = NullValueHandling.Ignore)] - public List Generic { get; set; } - /// - /// An array of the nodes that were triggered to create the response, in the order in which they were visited. - /// This information is useful for debugging and for tracing the path taken through the node tree. - /// - [JsonProperty("nodes_visited", NullValueHandling = NullValueHandling.Ignore)] - public List NodesVisited { get; set; } - /// - /// An array of objects containing detailed diagnostic information about the nodes that were triggered during - /// processing of the input message. Included only if **nodes_visited_details** is set to `true` in the message - /// request. - /// - [JsonProperty("nodes_visited_details", NullValueHandling = NullValueHandling.Ignore)] - public List NodesVisitedDetails { get; set; } + public List Generic { get; set; } } } diff --git a/Scripts/Services/Assistant/V1/Model/RuntimeEntity.cs b/Scripts/Services/Assistant/V1/Model/RuntimeEntity.cs index 95a078778..b14e57024 100644 --- a/Scripts/Services/Assistant/V1/Model/RuntimeEntity.cs +++ b/Scripts/Services/Assistant/V1/Model/RuntimeEntity.cs @@ -56,12 +56,5 @@ public class RuntimeEntity /// [JsonProperty("groups", NullValueHandling = NullValueHandling.Ignore)] public List Groups { get; set; } - /// - /// An object containing detailed information about the entity recognized in the user input. - /// - /// This property is a part of the new system entities, which are a beta feature. - /// - [JsonProperty("interpretation", NullValueHandling = NullValueHandling.Ignore)] - public RuntimeEntityInterpretation Interpretation { get; set; } } } diff --git a/Scripts/Services/Assistant/V1/Model/RuntimeEntityInterpretation.cs b/Scripts/Services/Assistant/V1/Model/RuntimeEntityInterpretation.cs deleted file mode 100644 index 533347572..000000000 --- a/Scripts/Services/Assistant/V1/Model/RuntimeEntityInterpretation.cs +++ /dev/null @@ -1,234 +0,0 @@ -/** -* Copyright 2018, 2019 IBM Corp. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -*/ - -using Newtonsoft.Json; - -namespace IBM.Watson.Assistant.V1.Model -{ - /// - /// RuntimeEntityInterpretation. - /// - public class RuntimeEntityInterpretation - { - /// - /// The precision or duration of a time range specified by a recognized `@sys-time` or `@sys-date` entity. - /// - public class GranularityValue - { - /// - /// Constant DAY for day - /// - public const string DAY = "day"; - /// - /// Constant FORTNIGHT for fortnight - /// - public const string FORTNIGHT = "fortnight"; - /// - /// Constant HOUR for hour - /// - public const string HOUR = "hour"; - /// - /// Constant INSTANT for instant - /// - public const string INSTANT = "instant"; - /// - /// Constant MINUTE for minute - /// - public const string MINUTE = "minute"; - /// - /// Constant MONTH for month - /// - public const string MONTH = "month"; - /// - /// Constant QUARTER for quarter - /// - public const string QUARTER = "quarter"; - /// - /// Constant SECOND for second - /// - public const string SECOND = "second"; - /// - /// Constant WEEK for week - /// - public const string WEEK = "week"; - /// - /// Constant WEEKEND for weekend - /// - public const string WEEKEND = "weekend"; - /// - /// Constant YEAR for year - /// - public const string YEAR = "year"; - - } - - /// - /// The precision or duration of a time range specified by a recognized `@sys-time` or `@sys-date` entity. - /// Constants for possible values can be found using RuntimeEntityInterpretation.GranularityValue - /// - [JsonProperty("granularity", NullValueHandling = NullValueHandling.Ignore)] - public string Granularity { get; set; } - /// - /// The calendar used to represent a recognized date (for example, `Gregorian`). - /// - [JsonProperty("calendar_type", NullValueHandling = NullValueHandling.Ignore)] - public string CalendarType { get; set; } - /// - /// A unique identifier used to associate a recognized time and date. If the user input contains a date and time - /// that are mentioned together (for example, `Today at 5`, the same **datetime_link** value is returned for - /// both the `@sys-date` and `@sys-time` entities). - /// - [JsonProperty("datetime_link", NullValueHandling = NullValueHandling.Ignore)] - public string DatetimeLink { get; set; } - /// - /// A locale-specific holiday name (such as `thanksgiving` or `christmas`). This property is included when a - /// `@sys-date` entity is recognized based on a holiday name in the user input. - /// - [JsonProperty("festival", NullValueHandling = NullValueHandling.Ignore)] - public string Festival { get; set; } - /// - /// A unique identifier used to associate multiple recognized `@sys-date`, `@sys-time`, or `@sys-number` - /// entities that are recognized as a range of values in the user's input (for example, `from July 4 until July - /// 14` or `from 20 to 25`). - /// - [JsonProperty("range_link", NullValueHandling = NullValueHandling.Ignore)] - public string RangeLink { get; set; } - /// - /// The word in the user input that indicates that a `sys-date` or `sys-time` entity is part of an implied range - /// where only one date or time is specified (for example, `since` or `until`). - /// - [JsonProperty("range_modifier", NullValueHandling = NullValueHandling.Ignore)] - public string RangeModifier { get; set; } - /// - /// A recognized mention of a relative day, represented numerically as an offset from the current date (for - /// example, `-1` for `yesterday` or `10` for `in ten days`). - /// - [JsonProperty("relative_day", NullValueHandling = NullValueHandling.Ignore)] - public float? RelativeDay { get; set; } - /// - /// A recognized mention of a relative month, represented numerically as an offset from the current month (for - /// example, `1` for `next month` or `-3` for `three months ago`). - /// - [JsonProperty("relative_month", NullValueHandling = NullValueHandling.Ignore)] - public float? RelativeMonth { get; set; } - /// - /// A recognized mention of a relative week, represented numerically as an offset from the current week (for - /// example, `2` for `in two weeks` or `-1` for `last week). - /// - [JsonProperty("relative_week", NullValueHandling = NullValueHandling.Ignore)] - public float? RelativeWeek { get; set; } - /// - /// A recognized mention of a relative date range for a weekend, represented numerically as an offset from the - /// current weekend (for example, `0` for `this weekend` or `-1` for `last weekend`). - /// - [JsonProperty("relative_weekend", NullValueHandling = NullValueHandling.Ignore)] - public float? RelativeWeekend { get; set; } - /// - /// A recognized mention of a relative year, represented numerically as an offset from the current year (for - /// example, `1` for `next year` or `-5` for `five years ago`). - /// - [JsonProperty("relative_year", NullValueHandling = NullValueHandling.Ignore)] - public float? RelativeYear { get; set; } - /// - /// A recognized mention of a specific date, represented numerically as the date within the month (for example, - /// `30` for `June 30`.). - /// - [JsonProperty("specific_day", NullValueHandling = NullValueHandling.Ignore)] - public float? SpecificDay { get; set; } - /// - /// A recognized mention of a specific day of the week as a lowercase string (for example, `monday`). - /// - [JsonProperty("specific_day_of_week", NullValueHandling = NullValueHandling.Ignore)] - public string SpecificDayOfWeek { get; set; } - /// - /// A recognized mention of a specific month, represented numerically (for example, `7` for `July`). - /// - [JsonProperty("specific_month", NullValueHandling = NullValueHandling.Ignore)] - public float? SpecificMonth { get; set; } - /// - /// A recognized mention of a specific quarter, represented numerically (for example, `3` for `the third - /// quarter`). - /// - [JsonProperty("specific_quarter", NullValueHandling = NullValueHandling.Ignore)] - public float? SpecificQuarter { get; set; } - /// - /// A recognized mention of a specific year (for example, `2016`). - /// - [JsonProperty("specific_year", NullValueHandling = NullValueHandling.Ignore)] - public float? SpecificYear { get; set; } - /// - /// A recognized numeric value, represented as an integer or double. - /// - [JsonProperty("numeric_value", NullValueHandling = NullValueHandling.Ignore)] - public float? NumericValue { get; set; } - /// - /// The type of numeric value recognized in the user input (`integer` or `rational`). - /// - [JsonProperty("subtype", NullValueHandling = NullValueHandling.Ignore)] - public string Subtype { get; set; } - /// - /// A recognized term for a time that was mentioned as a part of the day in the user's input (for example, - /// `morning` or `afternoon`). In addition, the returned entity value is set to a specific time: - /// - /// - `09:00:00` for `morning` - /// - `15:00:00` for `afternoon` - /// - `18:00:00` for `evening` - /// - `22:00:00` for `night` - /// - `00:00:00` for `midnight`. - /// - [JsonProperty("part_of_day", NullValueHandling = NullValueHandling.Ignore)] - public string PartOfDay { get; set; } - /// - /// A recognized mention of a relative hour, represented numerically as an offset from the current hour (for - /// example, `3` for `in three hours` or `-1` for `an hour ago`). - /// - [JsonProperty("relative_hour", NullValueHandling = NullValueHandling.Ignore)] - public float? RelativeHour { get; set; } - /// - /// A recognized mention of a relative time, represented numerically as an offset in minutes from the current - /// time (for example, `5` for `in five minutes` or `-15` for `fifteen minutes ago`). - /// - [JsonProperty("relative_minute", NullValueHandling = NullValueHandling.Ignore)] - public float? RelativeMinute { get; set; } - /// - /// A recognized mention of a relative time, represented numerically as an offset in seconds from the current - /// time (for example, `10` for `in ten seconds` or `-30` for `thirty seconds ago`). - /// - [JsonProperty("relative_second", NullValueHandling = NullValueHandling.Ignore)] - public float? RelativeSecond { get; set; } - /// - /// A recognized specific hour mentioned as part of a time value (for example, `10` for `10:15 AM`.). - /// - [JsonProperty("specific_hour", NullValueHandling = NullValueHandling.Ignore)] - public float? SpecificHour { get; set; } - /// - /// A recognized specific minute mentioned as part of a time value (for example, `15` for `10:15 AM`.). - /// - [JsonProperty("specific_minute", NullValueHandling = NullValueHandling.Ignore)] - public float? SpecificMinute { get; set; } - /// - /// A recognized specific second mentioned as part of a time value (for example, `30` for `10:15:30 AM`.). - /// - [JsonProperty("specific_second", NullValueHandling = NullValueHandling.Ignore)] - public float? SpecificSecond { get; set; } - /// - /// A recognized time zone mentioned as part of a time value (for example, `EST`). - /// - [JsonProperty("timezone", NullValueHandling = NullValueHandling.Ignore)] - public string Timezone { get; set; } - } -} diff --git a/Scripts/Services/Assistant/V1/Model/RuntimeResponseGeneric.cs b/Scripts/Services/Assistant/V1/Model/RuntimeResponseGeneric.cs new file mode 100644 index 000000000..c3f570fbe --- /dev/null +++ b/Scripts/Services/Assistant/V1/Model/RuntimeResponseGeneric.cs @@ -0,0 +1,157 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace IBM.Watson.Assistant.V1.Model +{ + /// + /// RuntimeResponseGeneric. + /// + public class RuntimeResponseGeneric + { + /// + /// The type of response returned by the dialog node. The specified response type must be supported by the + /// client application or channel. + /// + /// **Note:** The **suggestion** response type is part of the disambiguation feature, which is only available + /// for Plus and Premium users. + /// + public class ResponseTypeValue + { + /// + /// Constant TEXT for text + /// + public const string TEXT = "text"; + /// + /// Constant PAUSE for pause + /// + public const string PAUSE = "pause"; + /// + /// Constant IMAGE for image + /// + public const string IMAGE = "image"; + /// + /// Constant OPTION for option + /// + public const string OPTION = "option"; + /// + /// Constant CONNECT_TO_AGENT for connect_to_agent + /// + public const string CONNECT_TO_AGENT = "connect_to_agent"; + /// + /// Constant SUGGESTION for suggestion + /// + public const string SUGGESTION = "suggestion"; + + } + + /// + /// The preferred type of control to display. + /// + public class PreferenceValue + { + /// + /// Constant DROPDOWN for dropdown + /// + public const string DROPDOWN = "dropdown"; + /// + /// Constant BUTTON for button + /// + public const string BUTTON = "button"; + + } + + /// + /// The type of response returned by the dialog node. The specified response type must be supported by the + /// client application or channel. + /// + /// **Note:** The **suggestion** response type is part of the disambiguation feature, which is only available + /// for Plus and Premium users. + /// Constants for possible values can be found using RuntimeResponseGeneric.ResponseTypeValue + /// + [JsonProperty("response_type", NullValueHandling = NullValueHandling.Ignore)] + public string ResponseType { get; set; } + /// + /// The preferred type of control to display. + /// Constants for possible values can be found using RuntimeResponseGeneric.PreferenceValue + /// + [JsonProperty("preference", NullValueHandling = NullValueHandling.Ignore)] + public string Preference { get; set; } + /// + /// The text of the response. + /// + [JsonProperty("text", NullValueHandling = NullValueHandling.Ignore)] + public string Text { get; set; } + /// + /// How long to pause, in milliseconds. + /// + [JsonProperty("time", NullValueHandling = NullValueHandling.Ignore)] + public long? Time { get; set; } + /// + /// Whether to send a "user is typing" event during the pause. + /// + [JsonProperty("typing", NullValueHandling = NullValueHandling.Ignore)] + public bool? Typing { get; set; } + /// + /// The URL of the image. + /// + [JsonProperty("source", NullValueHandling = NullValueHandling.Ignore)] + public string Source { get; set; } + /// + /// The title or introductory text to show before the response. + /// + [JsonProperty("title", NullValueHandling = NullValueHandling.Ignore)] + public string Title { get; set; } + /// + /// The description to show with the the response. + /// + [JsonProperty("description", NullValueHandling = NullValueHandling.Ignore)] + public string Description { get; set; } + /// + /// An array of objects describing the options from which the user can choose. + /// + [JsonProperty("options", NullValueHandling = NullValueHandling.Ignore)] + public List Options { get; set; } + /// + /// A message to be sent to the human agent who will be taking over the conversation. + /// + [JsonProperty("message_to_human_agent", NullValueHandling = NullValueHandling.Ignore)] + public string MessageToHumanAgent { get; set; } + /// + /// A label identifying the topic of the conversation, derived from the **user_label** property of the relevant + /// node. + /// + [JsonProperty("topic", NullValueHandling = NullValueHandling.Ignore)] + public virtual string Topic { get; private set; } + /// + /// The ID of the dialog node that the **topic** property is taken from. The **topic** property is populated + /// using the value of the dialog node's **user_label** property. + /// + [JsonProperty("dialog_node", NullValueHandling = NullValueHandling.Ignore)] + public string DialogNode { get; set; } + /// + /// An array of objects describing the possible matching dialog nodes from which the user can choose. + /// + /// **Note:** The **suggestions** property is part of the disambiguation feature, which is only available for + /// Premium users. + /// + [JsonProperty("suggestions", NullValueHandling = NullValueHandling.Ignore)] + public List Suggestions { get; set; } + } +} diff --git a/Scripts/Services/Assistant/V1/Model/Value.cs b/Scripts/Services/Assistant/V1/Model/Value.cs index 211d819b2..2e4f9cc25 100644 --- a/Scripts/Services/Assistant/V1/Model/Value.cs +++ b/Scripts/Services/Assistant/V1/Model/Value.cs @@ -29,7 +29,7 @@ public class Value /// /// Specifies the type of entity value. /// - public class ValueTypeValue + public class TypeValue { /// /// Constant SYNONYMS for synonyms @@ -44,10 +44,10 @@ public class ValueTypeValue /// /// Specifies the type of entity value. - /// Constants for possible values can be found using Value.ValueTypeValue + /// Constants for possible values can be found using Value.TypeValue /// [JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)] - public string ValueType { get; set; } + public string Type { get; set; } /// /// The text of the entity value. This string must conform to the following restrictions: /// - It cannot contain carriage return, newline, or tab characters. diff --git a/Scripts/Services/Assistant/V2/AssistantService.cs b/Scripts/Services/Assistant/V2/AssistantService.cs index 03eff5dec..ff823fa84 100644 --- a/Scripts/Services/Assistant/V2/AssistantService.cs +++ b/Scripts/Services/Assistant/V2/AssistantService.cs @@ -117,7 +117,7 @@ public AssistantService(string versionDate, Authenticator authenticator) : base( } else { - 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"); + 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"); } } diff --git a/Scripts/Services/Assistant/V2/Model/DialogNodeAction.cs b/Scripts/Services/Assistant/V2/Model/DialogNodeAction.cs index 71fd571dc..06faba5ec 100644 --- a/Scripts/Services/Assistant/V2/Model/DialogNodeAction.cs +++ b/Scripts/Services/Assistant/V2/Model/DialogNodeAction.cs @@ -28,7 +28,7 @@ public class DialogNodeAction /// /// The type of action to invoke. /// - public class ActionTypeValue + public class TypeValue { /// /// Constant CLIENT for client @@ -51,10 +51,10 @@ public class ActionTypeValue /// /// The type of action to invoke. - /// Constants for possible values can be found using DialogNodeAction.ActionTypeValue + /// Constants for possible values can be found using DialogNodeAction.TypeValue /// [JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)] - public string ActionType { get; set; } + public string Type { get; set; } /// /// The name of the action. /// diff --git a/Scripts/Services/Assistant/V2/Model/MessageOutput.cs b/Scripts/Services/Assistant/V2/Model/MessageOutput.cs index f268d4cf8..212e8c567 100644 --- a/Scripts/Services/Assistant/V2/Model/MessageOutput.cs +++ b/Scripts/Services/Assistant/V2/Model/MessageOutput.cs @@ -30,7 +30,7 @@ public class MessageOutput /// supported response types. /// [JsonProperty("generic", NullValueHandling = NullValueHandling.Ignore)] - public List Generic { get; set; } + public List Generic { get; set; } /// /// An array of intents recognized in the user input, sorted in descending order of confidence. /// diff --git a/Scripts/Services/Assistant/V2/Model/RuntimeEntity.cs b/Scripts/Services/Assistant/V2/Model/RuntimeEntity.cs index 3f1c13563..97a1445f5 100644 --- a/Scripts/Services/Assistant/V2/Model/RuntimeEntity.cs +++ b/Scripts/Services/Assistant/V2/Model/RuntimeEntity.cs @@ -56,12 +56,5 @@ public class RuntimeEntity /// [JsonProperty("groups", NullValueHandling = NullValueHandling.Ignore)] public List Groups { get; set; } - /// - /// An object containing detailed information about the entity recognized in the user input. - /// - /// This property is a part of the new system entities, which are a beta feature. - /// - [JsonProperty("interpretation", NullValueHandling = NullValueHandling.Ignore)] - public RuntimeEntityInterpretation Interpretation { get; set; } } } diff --git a/Scripts/Services/Assistant/V2/Model/RuntimeEntityInterpretation.cs b/Scripts/Services/Assistant/V2/Model/RuntimeEntityInterpretation.cs deleted file mode 100644 index 9c1e0cbfc..000000000 --- a/Scripts/Services/Assistant/V2/Model/RuntimeEntityInterpretation.cs +++ /dev/null @@ -1,234 +0,0 @@ -/** -* Copyright 2018, 2019 IBM Corp. All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -*/ - -using Newtonsoft.Json; - -namespace IBM.Watson.Assistant.V2.Model -{ - /// - /// RuntimeEntityInterpretation. - /// - public class RuntimeEntityInterpretation - { - /// - /// The precision or duration of a time range specified by a recognized `@sys-time` or `@sys-date` entity. - /// - public class GranularityValue - { - /// - /// Constant DAY for day - /// - public const string DAY = "day"; - /// - /// Constant FORTNIGHT for fortnight - /// - public const string FORTNIGHT = "fortnight"; - /// - /// Constant HOUR for hour - /// - public const string HOUR = "hour"; - /// - /// Constant INSTANT for instant - /// - public const string INSTANT = "instant"; - /// - /// Constant MINUTE for minute - /// - public const string MINUTE = "minute"; - /// - /// Constant MONTH for month - /// - public const string MONTH = "month"; - /// - /// Constant QUARTER for quarter - /// - public const string QUARTER = "quarter"; - /// - /// Constant SECOND for second - /// - public const string SECOND = "second"; - /// - /// Constant WEEK for week - /// - public const string WEEK = "week"; - /// - /// Constant WEEKEND for weekend - /// - public const string WEEKEND = "weekend"; - /// - /// Constant YEAR for year - /// - public const string YEAR = "year"; - - } - - /// - /// The precision or duration of a time range specified by a recognized `@sys-time` or `@sys-date` entity. - /// Constants for possible values can be found using RuntimeEntityInterpretation.GranularityValue - /// - [JsonProperty("granularity", NullValueHandling = NullValueHandling.Ignore)] - public string Granularity { get; set; } - /// - /// The calendar used to represent a recognized date (for example, `Gregorian`). - /// - [JsonProperty("calendar_type", NullValueHandling = NullValueHandling.Ignore)] - public string CalendarType { get; set; } - /// - /// A unique identifier used to associate a recognized time and date. If the user input contains a date and time - /// that are mentioned together (for example, `Today at 5`, the same **datetime_link** value is returned for - /// both the `@sys-date` and `@sys-time` entities). - /// - [JsonProperty("datetime_link", NullValueHandling = NullValueHandling.Ignore)] - public string DatetimeLink { get; set; } - /// - /// A locale-specific holiday name (such as `thanksgiving` or `christmas`). This property is included when a - /// `@sys-date` entity is recognized based on a holiday name in the user input. - /// - [JsonProperty("festival", NullValueHandling = NullValueHandling.Ignore)] - public string Festival { get; set; } - /// - /// A unique identifier used to associate multiple recognized `@sys-date`, `@sys-time`, or `@sys-number` - /// entities that are recognized as a range of values in the user's input (for example, `from July 4 until July - /// 14` or `from 20 to 25`). - /// - [JsonProperty("range_link", NullValueHandling = NullValueHandling.Ignore)] - public string RangeLink { get; set; } - /// - /// The word in the user input that indicates that a `sys-date` or `sys-time` entity is part of an implied range - /// where only one date or time is specified (for example, `since` or `until`). - /// - [JsonProperty("range_modifier", NullValueHandling = NullValueHandling.Ignore)] - public string RangeModifier { get; set; } - /// - /// A recognized mention of a relative day, represented numerically as an offset from the current date (for - /// example, `-1` for `yesterday` or `10` for `in ten days`). - /// - [JsonProperty("relative_day", NullValueHandling = NullValueHandling.Ignore)] - public float? RelativeDay { get; set; } - /// - /// A recognized mention of a relative month, represented numerically as an offset from the current month (for - /// example, `1` for `next month` or `-3` for `three months ago`). - /// - [JsonProperty("relative_month", NullValueHandling = NullValueHandling.Ignore)] - public float? RelativeMonth { get; set; } - /// - /// A recognized mention of a relative week, represented numerically as an offset from the current week (for - /// example, `2` for `in two weeks` or `-1` for `last week). - /// - [JsonProperty("relative_week", NullValueHandling = NullValueHandling.Ignore)] - public float? RelativeWeek { get; set; } - /// - /// A recognized mention of a relative date range for a weekend, represented numerically as an offset from the - /// current weekend (for example, `0` for `this weekend` or `-1` for `last weekend`). - /// - [JsonProperty("relative_weekend", NullValueHandling = NullValueHandling.Ignore)] - public float? RelativeWeekend { get; set; } - /// - /// A recognized mention of a relative year, represented numerically as an offset from the current year (for - /// example, `1` for `next year` or `-5` for `five years ago`). - /// - [JsonProperty("relative_year", NullValueHandling = NullValueHandling.Ignore)] - public float? RelativeYear { get; set; } - /// - /// A recognized mention of a specific date, represented numerically as the date within the month (for example, - /// `30` for `June 30`.). - /// - [JsonProperty("specific_day", NullValueHandling = NullValueHandling.Ignore)] - public float? SpecificDay { get; set; } - /// - /// A recognized mention of a specific day of the week as a lowercase string (for example, `monday`). - /// - [JsonProperty("specific_day_of_week", NullValueHandling = NullValueHandling.Ignore)] - public string SpecificDayOfWeek { get; set; } - /// - /// A recognized mention of a specific month, represented numerically (for example, `7` for `July`). - /// - [JsonProperty("specific_month", NullValueHandling = NullValueHandling.Ignore)] - public float? SpecificMonth { get; set; } - /// - /// A recognized mention of a specific quarter, represented numerically (for example, `3` for `the third - /// quarter`). - /// - [JsonProperty("specific_quarter", NullValueHandling = NullValueHandling.Ignore)] - public float? SpecificQuarter { get; set; } - /// - /// A recognized mention of a specific year (for example, `2016`). - /// - [JsonProperty("specific_year", NullValueHandling = NullValueHandling.Ignore)] - public float? SpecificYear { get; set; } - /// - /// A recognized numeric value, represented as an integer or double. - /// - [JsonProperty("numeric_value", NullValueHandling = NullValueHandling.Ignore)] - public float? NumericValue { get; set; } - /// - /// The type of numeric value recognized in the user input (`integer` or `rational`). - /// - [JsonProperty("subtype", NullValueHandling = NullValueHandling.Ignore)] - public string Subtype { get; set; } - /// - /// A recognized term for a time that was mentioned as a part of the day in the user's input (for example, - /// `morning` or `afternoon`). In addition, the returned entity value is set to a specific time: - /// - /// - `09:00:00` for `morning` - /// - `15:00:00` for `afternoon` - /// - `18:00:00` for `evening` - /// - `22:00:00` for `night` - /// - `00:00:00` for `midnight`. - /// - [JsonProperty("part_of_day", NullValueHandling = NullValueHandling.Ignore)] - public string PartOfDay { get; set; } - /// - /// A recognized mention of a relative hour, represented numerically as an offset from the current hour (for - /// example, `3` for `in three hours` or `-1` for `an hour ago`). - /// - [JsonProperty("relative_hour", NullValueHandling = NullValueHandling.Ignore)] - public float? RelativeHour { get; set; } - /// - /// A recognized mention of a relative time, represented numerically as an offset in minutes from the current - /// time (for example, `5` for `in five minutes` or `-15` for `fifteen minutes ago`). - /// - [JsonProperty("relative_minute", NullValueHandling = NullValueHandling.Ignore)] - public float? RelativeMinute { get; set; } - /// - /// A recognized mention of a relative time, represented numerically as an offset in seconds from the current - /// time (for example, `10` for `in ten seconds` or `-30` for `thirty seconds ago`). - /// - [JsonProperty("relative_second", NullValueHandling = NullValueHandling.Ignore)] - public float? RelativeSecond { get; set; } - /// - /// A recognized specific hour mentioned as part of a time value (for example, `10` for `10:15 AM`.). - /// - [JsonProperty("specific_hour", NullValueHandling = NullValueHandling.Ignore)] - public float? SpecificHour { get; set; } - /// - /// A recognized specific minute mentioned as part of a time value (for example, `15` for `10:15 AM`.). - /// - [JsonProperty("specific_minute", NullValueHandling = NullValueHandling.Ignore)] - public float? SpecificMinute { get; set; } - /// - /// A recognized specific second mentioned as part of a time value (for example, `30` for `10:15:30 AM`.). - /// - [JsonProperty("specific_second", NullValueHandling = NullValueHandling.Ignore)] - public float? SpecificSecond { get; set; } - /// - /// A recognized time zone mentioned as part of a time value (for example, `EST`). - /// - [JsonProperty("timezone", NullValueHandling = NullValueHandling.Ignore)] - public string Timezone { get; set; } - } -} diff --git a/Scripts/Services/Assistant/V2/Model/RuntimeResponseGeneric.cs b/Scripts/Services/Assistant/V2/Model/RuntimeResponseGeneric.cs new file mode 100644 index 000000000..912c64bcc --- /dev/null +++ b/Scripts/Services/Assistant/V2/Model/RuntimeResponseGeneric.cs @@ -0,0 +1,166 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace IBM.Watson.Assistant.V2.Model +{ + /// + /// RuntimeResponseGeneric. + /// + public class RuntimeResponseGeneric + { + /// + /// The type of response returned by the dialog node. The specified response type must be supported by the + /// client application or channel. + /// + /// **Note:** The **suggestion** response type is part of the disambiguation feature, which is only available + /// for Premium users. + /// + public class ResponseTypeValue + { + /// + /// Constant TEXT for text + /// + public const string TEXT = "text"; + /// + /// Constant PAUSE for pause + /// + public const string PAUSE = "pause"; + /// + /// Constant IMAGE for image + /// + public const string IMAGE = "image"; + /// + /// Constant OPTION for option + /// + public const string OPTION = "option"; + /// + /// Constant CONNECT_TO_AGENT for connect_to_agent + /// + public const string CONNECT_TO_AGENT = "connect_to_agent"; + /// + /// Constant SUGGESTION for suggestion + /// + public const string SUGGESTION = "suggestion"; + /// + /// Constant SEARCH for search + /// + public const string SEARCH = "search"; + + } + + /// + /// The preferred type of control to display. + /// + public class PreferenceValue + { + /// + /// Constant DROPDOWN for dropdown + /// + public const string DROPDOWN = "dropdown"; + /// + /// Constant BUTTON for button + /// + public const string BUTTON = "button"; + + } + + /// + /// The type of response returned by the dialog node. The specified response type must be supported by the + /// client application or channel. + /// + /// **Note:** The **suggestion** response type is part of the disambiguation feature, which is only available + /// for Premium users. + /// Constants for possible values can be found using RuntimeResponseGeneric.ResponseTypeValue + /// + [JsonProperty("response_type", NullValueHandling = NullValueHandling.Ignore)] + public string ResponseType { get; set; } + /// + /// The preferred type of control to display. + /// Constants for possible values can be found using RuntimeResponseGeneric.PreferenceValue + /// + [JsonProperty("preference", NullValueHandling = NullValueHandling.Ignore)] + public string Preference { get; set; } + /// + /// The text of the response. + /// + [JsonProperty("text", NullValueHandling = NullValueHandling.Ignore)] + public string Text { get; set; } + /// + /// How long to pause, in milliseconds. + /// + [JsonProperty("time", NullValueHandling = NullValueHandling.Ignore)] + public long? Time { get; set; } + /// + /// Whether to send a "user is typing" event during the pause. + /// + [JsonProperty("typing", NullValueHandling = NullValueHandling.Ignore)] + public bool? Typing { get; set; } + /// + /// The URL of the image. + /// + [JsonProperty("source", NullValueHandling = NullValueHandling.Ignore)] + public string Source { get; set; } + /// + /// The title or introductory text to show before the response. + /// + [JsonProperty("title", NullValueHandling = NullValueHandling.Ignore)] + public string Title { get; set; } + /// + /// The description to show with the the response. + /// + [JsonProperty("description", NullValueHandling = NullValueHandling.Ignore)] + public string Description { get; set; } + /// + /// An array of objects describing the options from which the user can choose. + /// + [JsonProperty("options", NullValueHandling = NullValueHandling.Ignore)] + public List Options { get; set; } + /// + /// A message to be sent to the human agent who will be taking over the conversation. + /// + [JsonProperty("message_to_human_agent", NullValueHandling = NullValueHandling.Ignore)] + public string MessageToHumanAgent { get; set; } + /// + /// A label identifying the topic of the conversation, derived from the **user_label** property of the relevant + /// node. + /// + [JsonProperty("topic", NullValueHandling = NullValueHandling.Ignore)] + public virtual string Topic { get; private set; } + /// + /// An array of objects describing the possible matching dialog nodes from which the user can choose. + /// + /// **Note:** The **suggestions** property is part of the disambiguation feature, which is only available for + /// Premium users. + /// + [JsonProperty("suggestions", NullValueHandling = NullValueHandling.Ignore)] + public List Suggestions { get; set; } + /// + /// The title or introductory text to show before the response. This text is defined in the search skill + /// configuration. + /// + [JsonProperty("header", NullValueHandling = NullValueHandling.Ignore)] + public string Header { get; set; } + /// + /// An array of objects containing search results. + /// + [JsonProperty("results", NullValueHandling = NullValueHandling.Ignore)] + public List Results { get; set; } + } +} diff --git a/Scripts/Services/Assistant/V2/Model/SearchResult.cs b/Scripts/Services/Assistant/V2/Model/SearchResult.cs index 84887a3aa..3b51f47c1 100644 --- a/Scripts/Services/Assistant/V2/Model/SearchResult.cs +++ b/Scripts/Services/Assistant/V2/Model/SearchResult.cs @@ -16,6 +16,7 @@ */ using Newtonsoft.Json; +using Newtonsoft.Json.Linq; namespace IBM.Watson.Assistant.V2.Model { @@ -59,6 +60,6 @@ public class SearchResult /// tags. /// [JsonProperty("highlight", NullValueHandling = NullValueHandling.Ignore)] - public SearchResultHighlight Highlight { get; set; } + public JObject Highlight { get; set; } } } diff --git a/Scripts/Services/CompareComply/V1/CompareComplyService.cs b/Scripts/Services/CompareComply/V1/CompareComplyService.cs index 7a51316c6..d173c4530 100644 --- a/Scripts/Services/CompareComply/V1/CompareComplyService.cs +++ b/Scripts/Services/CompareComply/V1/CompareComplyService.cs @@ -117,7 +117,7 @@ public CompareComplyService(string versionDate, Authenticator authenticator) : b } else { - throw new IBMException("Please provide a username and password or authorization token to use the CompareComply service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-authenticator"); + throw new IBMException("Please provide a username and password or authorization token to use the CompareComply service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-credentials"); } } diff --git a/Scripts/Services/Discovery/V1/DiscoveryService.cs b/Scripts/Services/Discovery/V1/DiscoveryService.cs index 6f47698ce..2897f91af 100644 --- a/Scripts/Services/Discovery/V1/DiscoveryService.cs +++ b/Scripts/Services/Discovery/V1/DiscoveryService.cs @@ -117,7 +117,7 @@ public DiscoveryService(string versionDate, Authenticator authenticator) : base( } else { - throw new IBMException("Please provide a username and password or authorization token to use the Discovery service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-authenticator"); + throw new IBMException("Please provide a username and password or authorization token to use the Discovery service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-credentials"); } } diff --git a/Scripts/Services/Discovery/V1/Model/CredentialDetails.cs b/Scripts/Services/Discovery/V1/Model/CredentialDetails.cs index 10035664a..b31507e52 100644 --- a/Scripts/Services/Discovery/V1/Model/CredentialDetails.cs +++ b/Scripts/Services/Discovery/V1/Model/CredentialDetails.cs @@ -30,12 +30,12 @@ public class CredentialDetails /// The authentication method for this credentials definition. The **credential_type** specified must be /// supported by the **source_type**. The following combinations are possible: /// - /// - `\"source_type\": \"box\"` - valid `credential_type`s: `oauth2` - /// - `\"source_type\": \"salesforce\"` - valid `credential_type`s: `username_password` - /// - `\"source_type\": \"sharepoint\"` - valid `credential_type`s: `saml` with **source_version** of `online`, - /// or `ntlm_v1` with **source_version** of `2016` - /// - `\"source_type\": \"web_crawl\"` - valid `credential_type`s: `noauth` or `basic` - /// - \"source_type\": \"cloud_object_storage\"` - valid `credential_type`s: `aws4_hmac`. + /// - `"source_type": "box"` - valid `credential_type`s: `oauth2` + /// - `"source_type": "salesforce"` - valid `credential_type`s: `username_password` + /// - `"source_type": "sharepoint"` - valid `credential_type`s: `saml` with **source_version** of `online`, or + /// `ntlm_v1` with **source_version** of `2016` + /// - `"source_type": "web_crawl"` - valid `credential_type`s: `noauth` or `basic` + /// - "source_type": "cloud_object_storage"` - valid `credential_type`s: `aws4_hmac`. /// public class CredentialTypeValue { @@ -87,12 +87,12 @@ public class SourceVersionValue /// The authentication method for this credentials definition. The **credential_type** specified must be /// supported by the **source_type**. The following combinations are possible: /// - /// - `\"source_type\": \"box\"` - valid `credential_type`s: `oauth2` - /// - `\"source_type\": \"salesforce\"` - valid `credential_type`s: `username_password` - /// - `\"source_type\": \"sharepoint\"` - valid `credential_type`s: `saml` with **source_version** of `online`, - /// or `ntlm_v1` with **source_version** of `2016` - /// - `\"source_type\": \"web_crawl\"` - valid `credential_type`s: `noauth` or `basic` - /// - \"source_type\": \"cloud_object_storage\"` - valid `credential_type`s: `aws4_hmac`. + /// - `"source_type": "box"` - valid `credential_type`s: `oauth2` + /// - `"source_type": "salesforce"` - valid `credential_type`s: `username_password` + /// - `"source_type": "sharepoint"` - valid `credential_type`s: `saml` with **source_version** of `online`, or + /// `ntlm_v1` with **source_version** of `2016` + /// - `"source_type": "web_crawl"` - valid `credential_type`s: `noauth` or `basic` + /// - "source_type": "cloud_object_storage"` - valid `credential_type`s: `aws4_hmac`. /// Constants for possible values can be found using CredentialDetails.CredentialTypeValue /// [JsonProperty("credential_type", NullValueHandling = NullValueHandling.Ignore)] diff --git a/Scripts/Services/Discovery/V1/Model/Enrichment.cs b/Scripts/Services/Discovery/V1/Model/Enrichment.cs index 7df2e2c23..b2a5bf901 100644 --- a/Scripts/Services/Discovery/V1/Model/Enrichment.cs +++ b/Scripts/Services/Discovery/V1/Model/Enrichment.cs @@ -61,7 +61,7 @@ public class Enrichment /// documentation](https://cloud.ibm.com/docs/services/discovery?topic=discovery-element-classification#element-classification). /// [JsonProperty("enrichment", NullValueHandling = NullValueHandling.Ignore)] - public string EnrichmentName { get; set; } + public string _Enrichment { get; set; } /// /// If true, then most errors generated during the enrichment process will be treated as warnings and will not /// cause the document to fail processing. diff --git a/Scripts/Services/Discovery/V1/Model/Field.cs b/Scripts/Services/Discovery/V1/Model/Field.cs index 0979e78f9..6daa9daf9 100644 --- a/Scripts/Services/Discovery/V1/Model/Field.cs +++ b/Scripts/Services/Discovery/V1/Model/Field.cs @@ -27,7 +27,7 @@ public class Field /// /// The type of the field. /// - public class FieldTypeValue + public class TypeValue { /// /// Constant NESTED for nested @@ -78,14 +78,14 @@ public class FieldTypeValue /// /// The type of the field. - /// Constants for possible values can be found using Field.FieldTypeValue + /// Constants for possible values can be found using Field.TypeValue /// [JsonProperty("type", NullValueHandling = NullValueHandling.Ignore)] - public string FieldType { get; set; } + public string Type { get; set; } /// /// The name of the field. /// [JsonProperty("field", NullValueHandling = NullValueHandling.Ignore)] - public virtual string FieldName { get; private set; } + public virtual string _Field { get; private set; } } } diff --git a/Scripts/Services/LanguageTranslator/V3/LanguageTranslatorService.cs b/Scripts/Services/LanguageTranslator/V3/LanguageTranslatorService.cs index 09eeaa855..45124b7a0 100644 --- a/Scripts/Services/LanguageTranslator/V3/LanguageTranslatorService.cs +++ b/Scripts/Services/LanguageTranslator/V3/LanguageTranslatorService.cs @@ -117,7 +117,7 @@ public LanguageTranslatorService(string versionDate, Authenticator authenticator } else { - throw new IBMException("Please provide a username and password or authorization token to use the LanguageTranslator service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-authenticator"); + throw new IBMException("Please provide a username and password or authorization token to use the LanguageTranslator service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-credentials"); } } diff --git a/Scripts/Services/LanguageTranslator/V3/Model/DeleteModelResult.cs b/Scripts/Services/LanguageTranslator/V3/Model/DeleteModelResult.cs index ae30b5229..1e5c9b391 100644 --- a/Scripts/Services/LanguageTranslator/V3/Model/DeleteModelResult.cs +++ b/Scripts/Services/LanguageTranslator/V3/Model/DeleteModelResult.cs @@ -25,7 +25,7 @@ namespace IBM.Watson.LanguageTranslator.V3.Model public class DeleteModelResult { /// - /// \"OK\" indicates that the model was successfully deleted. + /// "OK" indicates that the model was successfully deleted. /// [JsonProperty("status", NullValueHandling = NullValueHandling.Ignore)] public string Status { get; set; } diff --git a/Scripts/Services/LanguageTranslator/V3/Model/Translation.cs b/Scripts/Services/LanguageTranslator/V3/Model/Translation.cs index 4775a708d..373b2a192 100644 --- a/Scripts/Services/LanguageTranslator/V3/Model/Translation.cs +++ b/Scripts/Services/LanguageTranslator/V3/Model/Translation.cs @@ -28,6 +28,6 @@ public class Translation /// Translation output in UTF-8. /// [JsonProperty("translation", NullValueHandling = NullValueHandling.Ignore)] - public string TranslationOutput { get; set; } + public string _Translation { get; set; } } } diff --git a/Scripts/Services/NaturalLanguageClassifier/V1/NaturalLanguageClassifierService.cs b/Scripts/Services/NaturalLanguageClassifier/V1/NaturalLanguageClassifierService.cs index 7af74c421..3461578ca 100644 --- a/Scripts/Services/NaturalLanguageClassifier/V1/NaturalLanguageClassifierService.cs +++ b/Scripts/Services/NaturalLanguageClassifier/V1/NaturalLanguageClassifierService.cs @@ -99,7 +99,7 @@ public NaturalLanguageClassifierService(Authenticator authenticator) : base(auth } else { - throw new IBMException("Please provide a username and password or authorization token to use the NaturalLanguageClassifier service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-authenticator"); + throw new IBMException("Please provide a username and password or authorization token to use the NaturalLanguageClassifier service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-credentials"); } } diff --git a/Scripts/Services/NaturalLanguageUnderstanding/V1/Model/SemanticRolesResult.cs b/Scripts/Services/NaturalLanguageUnderstanding/V1/Model/SemanticRolesResult.cs index 4ccdef819..dc38677fc 100644 --- a/Scripts/Services/NaturalLanguageUnderstanding/V1/Model/SemanticRolesResult.cs +++ b/Scripts/Services/NaturalLanguageUnderstanding/V1/Model/SemanticRolesResult.cs @@ -43,6 +43,6 @@ public class SemanticRolesResult /// The extracted object from the sentence. /// [JsonProperty("object", NullValueHandling = NullValueHandling.Ignore)] - public SemanticRolesResultObject _Object { get; set; } + public SemanticRolesResultModelObject _Object { get; set; } } } diff --git a/Scripts/Services/NaturalLanguageUnderstanding/V1/Model/SemanticRolesResultModelObject.cs b/Scripts/Services/NaturalLanguageUnderstanding/V1/Model/SemanticRolesResultModelObject.cs new file mode 100644 index 000000000..20722439e --- /dev/null +++ b/Scripts/Services/NaturalLanguageUnderstanding/V1/Model/SemanticRolesResultModelObject.cs @@ -0,0 +1,39 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace IBM.Watson.NaturalLanguageUnderstanding.V1.Model +{ + /// + /// The extracted object from the sentence. + /// + public class SemanticRolesResultModelObject + { + /// + /// Object text. + /// + [JsonProperty("text", NullValueHandling = NullValueHandling.Ignore)] + public string Text { get; set; } + /// + /// An array of extracted keywords. + /// + [JsonProperty("keywords", NullValueHandling = NullValueHandling.Ignore)] + public List Keywords { get; set; } + } +} diff --git a/Scripts/Services/NaturalLanguageUnderstanding/V1/NaturalLanguageUnderstandingService.cs b/Scripts/Services/NaturalLanguageUnderstanding/V1/NaturalLanguageUnderstandingService.cs index 035102d06..2a82acba8 100644 --- a/Scripts/Services/NaturalLanguageUnderstanding/V1/NaturalLanguageUnderstandingService.cs +++ b/Scripts/Services/NaturalLanguageUnderstanding/V1/NaturalLanguageUnderstandingService.cs @@ -117,7 +117,7 @@ public NaturalLanguageUnderstandingService(string versionDate, Authenticator aut } else { - throw new IBMException("Please provide a username and password or authorization token to use the NaturalLanguageUnderstanding service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-authenticator"); + throw new IBMException("Please provide a username and password or authorization token to use the NaturalLanguageUnderstanding service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-credentials"); } } diff --git a/Scripts/Services/PersonalityInsights/V3/Model/Warning.cs b/Scripts/Services/PersonalityInsights/V3/Model/Warning.cs index 667cf52dd..bb704b620 100644 --- a/Scripts/Services/PersonalityInsights/V3/Model/Warning.cs +++ b/Scripts/Services/PersonalityInsights/V3/Model/Warning.cs @@ -56,15 +56,15 @@ public class WarningIdValue public string WarningId { get; set; } /// /// The message associated with the `warning_id`: - /// * `WORD_COUNT_MESSAGE`: \"There were {number} words in the input. We need a minimum of 600, preferably 1,200 - /// or more, to compute statistically significant estimates.\" - /// * `JSON_AS_TEXT`: \"Request input was processed as text/plain as indicated, however detected a JSON input. - /// Did you mean application/json?\" - /// * `CONTENT_TRUNCATED`: \"For maximum accuracy while also optimizing processing time, only the first 250KB of + /// * `WORD_COUNT_MESSAGE`: "There were {number} words in the input. We need a minimum of 600, preferably 1,200 + /// or more, to compute statistically significant estimates." + /// * `JSON_AS_TEXT`: "Request input was processed as text/plain as indicated, however detected a JSON input. + /// Did you mean application/json?" + /// * `CONTENT_TRUNCATED`: "For maximum accuracy while also optimizing processing time, only the first 250KB of /// input text (excluding markup) was analyzed. Accuracy levels off at approximately 3,000 words so this did not - /// affect the accuracy of the profile.\" - /// * `PARTIAL_TEXT_USED`, \"The text provided to compute the profile was trimmed for performance reasons. This - /// action does not affect the accuracy of the output, as not all of the input text was required.\" Applies only + /// affect the accuracy of the profile." + /// * `PARTIAL_TEXT_USED`, "The text provided to compute the profile was trimmed for performance reasons. This + /// action does not affect the accuracy of the output, as not all of the input text was required." Applies only /// when Arabic input text exceeds a threshold at which additional words do not contribute to the accuracy of /// the profile. /// diff --git a/Scripts/Services/PersonalityInsights/V3/PersonalityInsightsService.cs b/Scripts/Services/PersonalityInsights/V3/PersonalityInsightsService.cs index 8e5df4446..cf20f6df4 100644 --- a/Scripts/Services/PersonalityInsights/V3/PersonalityInsightsService.cs +++ b/Scripts/Services/PersonalityInsights/V3/PersonalityInsightsService.cs @@ -117,7 +117,7 @@ public PersonalityInsightsService(string versionDate, Authenticator authenticato } else { - throw new IBMException("Please provide a username and password or authorization token to use the PersonalityInsights service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-authenticator"); + throw new IBMException("Please provide a username and password or authorization token to use the PersonalityInsights service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-credentials"); } } diff --git a/Scripts/Services/SpeechToText/V1/Model/LanguageModel.cs b/Scripts/Services/SpeechToText/V1/Model/LanguageModel.cs index 8ed880e14..ddabb3d8d 100644 --- a/Scripts/Services/SpeechToText/V1/Model/LanguageModel.cs +++ b/Scripts/Services/SpeechToText/V1/Model/LanguageModel.cs @@ -104,12 +104,14 @@ public class StatusValue [JsonProperty("language", NullValueHandling = NullValueHandling.Ignore)] public string Language { get; set; } /// - /// The dialect of the language for the custom language model. By default, the dialect matches the language of - /// the base model; for example, `en-US` for either of the US English language models. For Spanish models, the - /// field indicates the dialect for which the model was created: - /// * `es-ES` for Castilian Spanish (the default) - /// * `es-LA` for Latin American Spanish - /// * `es-US` for North American (Mexican) Spanish. + /// The dialect of the language for the custom language model. For non-Spanish models, the field matches the + /// language of the base model; for example, `en-US` for either of the US English language models. For Spanish + /// models, the field indicates the dialect for which the model was created: + /// * `es-ES` for Castilian Spanish (`es-ES` models) + /// * `es-LA` for Latin American Spanish (`es-AR`, `es-CL`, `es-CO`, and `es-PE` models) + /// * `es-US` for Mexican (North American) Spanish (`es-MX` models) + /// + /// Dialect values are case-insensitive. /// [JsonProperty("dialect", NullValueHandling = NullValueHandling.Ignore)] public string Dialect { get; set; } diff --git a/Scripts/Services/SpeechToText/V1/Model/RecognitionJob.cs b/Scripts/Services/SpeechToText/V1/Model/RecognitionJob.cs index fe9257ba2..339af8b35 100644 --- a/Scripts/Services/SpeechToText/V1/Model/RecognitionJob.cs +++ b/Scripts/Services/SpeechToText/V1/Model/RecognitionJob.cs @@ -109,9 +109,9 @@ public class StatusValue public List Results { get; set; } /// /// An array of warning messages about invalid parameters included with the request. Each warning includes a - /// descriptive message and a list of invalid argument strings, for example, `\"unexpected query parameter - /// 'user_token', query parameter 'callback_url' was not specified\"`. The request succeeds despite the - /// warnings. This field can be returned only by the **Create a job** method. + /// descriptive message and a list of invalid argument strings, for example, `"unexpected query parameter + /// 'user_token', query parameter 'callback_url' was not specified"`. The request succeeds despite the warnings. + /// This field can be returned only by the **Create a job** method. /// [JsonProperty("warnings", NullValueHandling = NullValueHandling.Ignore)] public List Warnings { get; set; } diff --git a/Scripts/Services/SpeechToText/V1/Model/SpeakerLabelsResult.cs b/Scripts/Services/SpeechToText/V1/Model/SpeakerLabelsResult.cs index a62b324da..4cb5f8cac 100644 --- a/Scripts/Services/SpeechToText/V1/Model/SpeakerLabelsResult.cs +++ b/Scripts/Services/SpeechToText/V1/Model/SpeakerLabelsResult.cs @@ -56,6 +56,6 @@ public class SpeakerLabelsResult /// `false` means that the service might send further updates to the results. /// [JsonProperty("final", NullValueHandling = NullValueHandling.Ignore)] - public bool? FinalResults { get; set; } + public bool? Final { get; set; } } } diff --git a/Scripts/Services/SpeechToText/V1/Model/SpeechRecognitionAlternative.cs b/Scripts/Services/SpeechToText/V1/Model/SpeechRecognitionAlternative.cs index 177c750d8..ad3876fb1 100644 --- a/Scripts/Services/SpeechToText/V1/Model/SpeechRecognitionAlternative.cs +++ b/Scripts/Services/SpeechToText/V1/Model/SpeechRecognitionAlternative.cs @@ -39,17 +39,17 @@ public class SpeechRecognitionAlternative /// /// Time alignments for each word from the transcript as a list of lists. Each inner list consists of three /// elements: the word followed by its start and end time in seconds, for example: - /// `[[\"hello\",0.0,1.2],[\"world\",1.2,2.5]]`. Timestamps are returned only for the best alternative. + /// `[["hello",0.0,1.2],["world",1.2,2.5]]`. Timestamps are returned only for the best alternative. /// [JsonProperty("timestamps", NullValueHandling = NullValueHandling.Ignore)] - public string[][] Timestamps { get; set; } + public List Timestamps { get; set; } /// /// A confidence score for each word of the transcript as a list of lists. Each inner list consists of two /// elements: the word and its confidence score in the range of 0.0 to 1.0, for example: - /// `[[\"hello\",0.95],[\"world\",0.866]]`. Confidence scores are returned only for the best alternative and - /// only with results marked as final. + /// `[["hello",0.95],["world",0.866]]`. Confidence scores are returned only for the best alternative and only + /// with results marked as final. /// [JsonProperty("word_confidence", NullValueHandling = NullValueHandling.Ignore)] - public string[][] WordConfidence { get; set; } + public List WordConfidence { get; set; } } } diff --git a/Scripts/Services/SpeechToText/V1/Model/SpeechRecognitionResult.cs b/Scripts/Services/SpeechToText/V1/Model/SpeechRecognitionResult.cs index 2f1c07dff..c458a5a27 100644 --- a/Scripts/Services/SpeechToText/V1/Model/SpeechRecognitionResult.cs +++ b/Scripts/Services/SpeechToText/V1/Model/SpeechRecognitionResult.cs @@ -31,7 +31,7 @@ public class SpeechRecognitionResult /// final. /// [JsonProperty("final", NullValueHandling = NullValueHandling.Ignore)] - public bool? FinalResults { get; set; } + public bool? Final { get; set; } /// /// An array of alternative transcripts. The `alternatives` array can include additional requested output such /// as word confidence or timestamps. diff --git a/Scripts/Services/SpeechToText/V1/Model/SpeechRecognitionResults.cs b/Scripts/Services/SpeechToText/V1/Model/SpeechRecognitionResults.cs index 5585b5ecd..631d004d0 100644 --- a/Scripts/Services/SpeechToText/V1/Model/SpeechRecognitionResults.cs +++ b/Scripts/Services/SpeechToText/V1/Model/SpeechRecognitionResults.cs @@ -62,13 +62,13 @@ public class SpeechRecognitionResults /// /// An array of warning messages associated with the request: /// * Warnings for invalid parameters or fields can include a descriptive message and a list of invalid argument - /// strings, for example, `\"Unknown arguments:\"` or `\"Unknown url query arguments:\"` followed by a list of - /// the form `\"{invalid_arg_1}, {invalid_arg_2}.\"` + /// strings, for example, `"Unknown arguments:"` or `"Unknown url query arguments:"` followed by a list of the + /// form `"{invalid_arg_1}, {invalid_arg_2}."` /// * The following warning is returned if the request passes a custom model that is based on an older version - /// of a base model for which an updated version is available: `\"Using previous version of base model, because + /// of a base model for which an updated version is available: `"Using previous version of base model, because /// your custom model has been built with it. Please note that this version will be supported only for a limited /// time. Consider updating your custom model to the new base model. If you do not do that you will be - /// automatically switched to base model when you used the non-updated custom model.\"` + /// automatically switched to base model when you used the non-updated custom model."` /// /// In both cases, the request succeeds despite the warnings. /// diff --git a/Scripts/Services/SpeechToText/V1/Model/TrainingResponse.cs b/Scripts/Services/SpeechToText/V1/Model/TrainingResponse.cs new file mode 100644 index 000000000..731e5e655 --- /dev/null +++ b/Scripts/Services/SpeechToText/V1/Model/TrainingResponse.cs @@ -0,0 +1,36 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace IBM.Watson.SpeechToText.V1.Model +{ + /// + /// The response from training of a custom language or custom acoustic model. + /// + public class TrainingResponse + { + /// + /// An array of `TrainingWarning` objects that lists any invalid resources contained in the custom model. For + /// custom language models, invalid resources are grouped and identified by type of resource. The method can + /// return warnings only if the `strict` parameter is set to `false`. + /// + [JsonProperty("warnings", NullValueHandling = NullValueHandling.Ignore)] + public List Warnings { get; set; } + } +} diff --git a/Scripts/Services/SpeechToText/V1/Model/TrainingWarning.cs b/Scripts/Services/SpeechToText/V1/Model/TrainingWarning.cs new file mode 100644 index 000000000..1be2cc357 --- /dev/null +++ b/Scripts/Services/SpeechToText/V1/Model/TrainingWarning.cs @@ -0,0 +1,65 @@ +/** +* Copyright 2018, 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using Newtonsoft.Json; + +namespace IBM.Watson.SpeechToText.V1.Model +{ + /// + /// A warning from training of a custom language or custom acoustic model. + /// + public class TrainingWarning + { + /// + /// An identifier for the type of invalid resources listed in the `description` field. + /// + public class CodeValue + { + /// + /// Constant INVALID_AUDIO_FILES for invalid_audio_files + /// + public const string INVALID_AUDIO_FILES = "invalid_audio_files"; + /// + /// Constant INVALID_CORPUS_FILES for invalid_corpus_files + /// + public const string INVALID_CORPUS_FILES = "invalid_corpus_files"; + /// + /// Constant INVALID_GRAMMAR_FILES for invalid_grammar_files + /// + public const string INVALID_GRAMMAR_FILES = "invalid_grammar_files"; + /// + /// Constant INVALID_WORDS for invalid_words + /// + public const string INVALID_WORDS = "invalid_words"; + + } + + /// + /// An identifier for the type of invalid resources listed in the `description` field. + /// Constants for possible values can be found using TrainingWarning.CodeValue + /// + [JsonProperty("code", NullValueHandling = NullValueHandling.Ignore)] + public string Code { get; set; } + /// + /// A warning message that lists the invalid resources that are excluded from the custom model's training. The + /// message has the following format: `Analysis of the following {resource_type} has not completed successfully: + /// [{resource_names}]. They will be excluded from custom {model_type} model training.`. + /// + [JsonProperty("message", NullValueHandling = NullValueHandling.Ignore)] + public string Message { get; set; } + } +} diff --git a/Scripts/Services/SpeechToText/V1/Model/WordError.cs b/Scripts/Services/SpeechToText/V1/Model/WordError.cs index 2050610a7..0db11e84a 100644 --- a/Scripts/Services/SpeechToText/V1/Model/WordError.cs +++ b/Scripts/Services/SpeechToText/V1/Model/WordError.cs @@ -26,10 +26,10 @@ public class WordError { /// /// A key-value pair that describes an error associated with the definition of a word in the words resource. The - /// pair has the format `\"element\": \"message\"`, where `element` is the aspect of the definition that caused - /// the problem and `message` describes the problem. The following example describes a problem with one of the - /// word's sounds-like definitions: `\"{sounds_like_string}\": \"Numbers are not allowed in sounds-like. You can - /// try for example '{suggested_string}'.\"`. + /// pair has the format `"element": "message"`, where `element` is the aspect of the definition that caused the + /// problem and `message` describes the problem. The following example describes a problem with one of the + /// word's sounds-like definitions: `"{sounds_like_string}": "Numbers are not allowed in sounds-like. You can + /// try for example '{suggested_string}'."`. /// [JsonProperty("element", NullValueHandling = NullValueHandling.Ignore)] public string Element { get; set; } diff --git a/Scripts/Services/SpeechToText/V1/SpeechToTextService.cs b/Scripts/Services/SpeechToText/V1/SpeechToTextService.cs index f38fcb922..334d5d8b9 100644 --- a/Scripts/Services/SpeechToText/V1/SpeechToTextService.cs +++ b/Scripts/Services/SpeechToText/V1/SpeechToTextService.cs @@ -99,7 +99,7 @@ public SpeechToTextService(Authenticator authenticator) : base(authenticator, se } else { - throw new IBMException("Please provide a username and password or authorization token to use the SpeechToText service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-authenticator"); + throw new IBMException("Please provide a username and password or authorization token to use the SpeechToText service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-credentials"); } } diff --git a/Scripts/Services/SpeechToText/V1/SpeechToTextServiceExtension.cs b/Scripts/Services/SpeechToText/V1/SpeechToTextServiceExtension.cs index 27e443133..3b9e13a28 100644 --- a/Scripts/Services/SpeechToText/V1/SpeechToTextServiceExtension.cs +++ b/Scripts/Services/SpeechToText/V1/SpeechToTextServiceExtension.cs @@ -16,6 +16,7 @@ */ using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; using IBM.Cloud.SDK.Connection; using IBM.Cloud.SDK.DataTypes; using IBM.Cloud.SDK.Utilities; @@ -107,8 +108,8 @@ public partial class SpeechToTextService : BaseService private bool _streamMultipart = false; // If true sets `Transfer-Encoding` header of multipart request to `chunked`. private float _silenceDuration = 0.0f; private float _silenceCutoff = 1.0f; - - private Credentials _credentials = null; + + private Authenticator _authenticator = null; private string _url = "https://stream.watsonplatform.net/speech-to-text/api"; #endregion @@ -292,7 +293,7 @@ public bool StartListening(OnRecognize callback, OnRecognizeSpeaker speakerLabel return false; if (!CreateListenConnector()) return false; - + Dictionary customHeaders = new Dictionary(); foreach (KeyValuePair kvp in customRequestHeaders) { @@ -445,7 +446,9 @@ private bool CreateListenConnector() parsedParams += string.Format("&{0}={1}", kvp.Key, kvp.Value); } - _listenSocket = WSConnector.CreateConnector(Credentials, "/v1/recognize", "?model=" + UnityWebRequest.EscapeURL(_recognizeModel) + parsedParams); + _listenSocket = WSConnector.CreateConnector(Authenticator, "/v1/recognize", "?model=" + UnityWebRequest.EscapeURL(_recognizeModel) + parsedParams); + Authenticator.Authenticate(_listenSocket); + Log.Debug("SpeechToText.CreateListenConnector()", "Created listen socket. Model: {0}, parsedParams: {1}", UnityWebRequest.EscapeURL(_recognizeModel), parsedParams); _listenSocket.DisableSslVerification = DisableSslVerification; if (_listenSocket == null) { diff --git a/Scripts/Services/TextToSpeech/V1/TextToSpeechService.cs b/Scripts/Services/TextToSpeech/V1/TextToSpeechService.cs index 33c9c8e72..51647a1a0 100644 --- a/Scripts/Services/TextToSpeech/V1/TextToSpeechService.cs +++ b/Scripts/Services/TextToSpeech/V1/TextToSpeechService.cs @@ -99,7 +99,7 @@ public TextToSpeechService(Authenticator authenticator) : base(authenticator, se } else { - throw new IBMException("Please provide a username and password or authorization token to use the TextToSpeech service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-authenticator"); + throw new IBMException("Please provide a username and password or authorization token to use the TextToSpeech service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-credentials"); } } diff --git a/Scripts/Services/ToneAnalyzer/V3/ToneAnalyzerService.cs b/Scripts/Services/ToneAnalyzer/V3/ToneAnalyzerService.cs index c8f8856b2..cc178138b 100644 --- a/Scripts/Services/ToneAnalyzer/V3/ToneAnalyzerService.cs +++ b/Scripts/Services/ToneAnalyzer/V3/ToneAnalyzerService.cs @@ -117,7 +117,7 @@ public ToneAnalyzerService(string versionDate, Authenticator authenticator) : ba } else { - throw new IBMException("Please provide a username and password or authorization token to use the ToneAnalyzer service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-authenticator"); + throw new IBMException("Please provide a username and password or authorization token to use the ToneAnalyzer service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-credentials"); } } diff --git a/Scripts/Services/VisualRecognition/V3/Model/ClassResult.cs b/Scripts/Services/VisualRecognition/V3/Model/ClassResult.cs index 43c657afc..d9279203e 100644 --- a/Scripts/Services/VisualRecognition/V3/Model/ClassResult.cs +++ b/Scripts/Services/VisualRecognition/V3/Model/ClassResult.cs @@ -33,7 +33,7 @@ public class ClassResult /// or when there is no translation for the class name. /// [JsonProperty("class", NullValueHandling = NullValueHandling.Ignore)] - public string ClassName { get; set; } + public string _Class { get; set; } /// /// Confidence score for the property in the range of 0 to 1. A higher score indicates greater likelihood that /// the class is depicted in the image. The default threshold for returning scores from a classifier is 0.5. diff --git a/Scripts/Services/VisualRecognition/V3/Model/FaceGender.cs b/Scripts/Services/VisualRecognition/V3/Model/FaceGender.cs index 4dc9dbd57..5f70d42c2 100644 --- a/Scripts/Services/VisualRecognition/V3/Model/FaceGender.cs +++ b/Scripts/Services/VisualRecognition/V3/Model/FaceGender.cs @@ -30,7 +30,7 @@ public class FaceGender [JsonProperty("gender", NullValueHandling = NullValueHandling.Ignore)] public string Gender { get; set; } /// - /// The word for \"male\" or \"female\" in the language defined by the **Accept-Language** request header. + /// The word for "male" or "female" in the language defined by the **Accept-Language** request header. /// [JsonProperty("gender_label", NullValueHandling = NullValueHandling.Ignore)] public string GenderLabel { get; set; } diff --git a/Scripts/Services/VisualRecognition/V3/Model/ModelClass.cs b/Scripts/Services/VisualRecognition/V3/Model/ModelClass.cs index 18e91f0f8..40c00d40c 100644 --- a/Scripts/Services/VisualRecognition/V3/Model/ModelClass.cs +++ b/Scripts/Services/VisualRecognition/V3/Model/ModelClass.cs @@ -28,6 +28,6 @@ public class ModelClass /// The name of the class. /// [JsonProperty("class", NullValueHandling = NullValueHandling.Ignore)] - public string ClassName { get; set; } + public string _Class { get; set; } } } diff --git a/Scripts/Services/VisualRecognition/V3/VisualRecognitionService.cs b/Scripts/Services/VisualRecognition/V3/VisualRecognitionService.cs index e6c9fb8e7..22cd528db 100644 --- a/Scripts/Services/VisualRecognition/V3/VisualRecognitionService.cs +++ b/Scripts/Services/VisualRecognition/V3/VisualRecognitionService.cs @@ -116,7 +116,7 @@ public VisualRecognitionService(string versionDate, Authenticator authenticator) } else { - throw new IBMException("Please provide a username and password or authorization token to use the VisualRecognition service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-authenticator"); + throw new IBMException("Please provide a username and password or authorization token to use the VisualRecognition service. For more information, see https://github.com/watson-developer-cloud/unity-sdk/#configuring-your-service-credentials"); } } diff --git a/Tests/AssistantV1IntegrationTests.cs b/Tests/AssistantV1IntegrationTests.cs index baacde9b2..606b64a64 100644 --- a/Tests/AssistantV1IntegrationTests.cs +++ b/Tests/AssistantV1IntegrationTests.cs @@ -19,6 +19,8 @@ using System.Collections; using System.Collections.Generic; using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; +using IBM.Cloud.SDK.Authentication.Iam; using IBM.Watson.Assistant.V1; using IBM.Watson.Assistant.V1.Model; using Newtonsoft.Json.Linq; @@ -69,10 +71,10 @@ public IEnumerator UnityTestSetup() { if (service == null) { - service = new AssistantService(versionDate); + service = new AssistantService(versionDate, authenticator); } - while (!service.Credentials.HasIamTokenData()) + while (!service.Authenticator.CanAuthenticate()) yield return null; } @@ -89,7 +91,7 @@ public IEnumerator TestMessage() JToken context = null; MessageResponse messageResponse = null; JToken conversationId = null; - Log.Debug("AssistantV1IntegrationTests", "Attempting to Message..."); + Log.Debug("AssistantV1IntegrationTests", "Attempting to Message...{0}...", workspaceId); service.Message( callback: (DetailedResponse response, IBMError error) => { @@ -325,7 +327,6 @@ public IEnumerator TestListWorkspaces() Assert.IsNull(error); }, pageLimit: 1, - includeCount: true, sort: "-name", includeAudit: true ); @@ -428,7 +429,6 @@ public IEnumerator TestListIntents() workspaceId: workspaceId, export: true, pageLimit: 1, - includeCount: true, sort: "-name", includeAudit: true ); @@ -527,7 +527,6 @@ public IEnumerator TestListExamples() workspaceId: workspaceId, intent: updatedIntentName, pageLimit: 1, - includeCount: true, sort: "-text", includeAudit: true ); @@ -622,7 +621,6 @@ public IEnumerator TestListCounterexamples() }, workspaceId: workspaceId, pageLimit: 1, - includeCount: true, sort: "-text", includeAudit: true ); @@ -722,7 +720,6 @@ public IEnumerator TestListEntities() workspaceId: workspaceId, export: true, pageLimit: 1, - includeCount: true, sort: "-entity", includeAudit: true ); @@ -848,7 +845,6 @@ public IEnumerator TestListValues() entity: updatedEntityName, export: true, pageLimit: 1, - includeCount: true, sort: "-value", includeAudit: true ); @@ -949,7 +945,6 @@ public IEnumerator TestListSynonyms() entity: updatedEntityName, value: updatedValueText, pageLimit: 1, - includeCount: true, sort: "-synonym", includeAudit: true ); @@ -1048,7 +1043,6 @@ public IEnumerator TestListDialogNodes() }, workspaceId: workspaceId, pageLimit: 1, - includeCount: true, sort: "-dialog_node", includeAudit: true ); diff --git a/Tests/AssistantV2IntegrationTests.cs b/Tests/AssistantV2IntegrationTests.cs index 83da83db9..d223de004 100644 --- a/Tests/AssistantV2IntegrationTests.cs +++ b/Tests/AssistantV2IntegrationTests.cs @@ -16,6 +16,7 @@ */ using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; using IBM.Watson.Assistant.V2; using IBM.Watson.Assistant.V2.Model; using NUnit.Framework; @@ -44,7 +45,7 @@ public IEnumerator TestMessage() { service = new AssistantService(versionDate); - while (!service.Credentials.HasIamTokenData()) + while (!service.Authenticator.CanAuthenticate()) yield return null; assistantId = Environment.GetEnvironmentVariable("ASSISTANT_ASSISTANT_ID"); diff --git a/Tests/CompareComplyV1IntegrationTests.cs b/Tests/CompareComplyV1IntegrationTests.cs index fb124e178..40bc4cb38 100644 --- a/Tests/CompareComplyV1IntegrationTests.cs +++ b/Tests/CompareComplyV1IntegrationTests.cs @@ -19,6 +19,7 @@ using System.Collections.Generic; using System.IO; using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; using IBM.Cloud.SDK.Utilities; using IBM.Watson.CompareComply.V1; using IBM.Watson.CompareComply.V1.Model; @@ -63,7 +64,7 @@ public IEnumerator UnityTestSetup() service = new CompareComplyService(versionDate); } - while (!service.Credentials.HasIamTokenData()) + while (!service.Authenticator.CanAuthenticate()) yield return null; } @@ -94,7 +95,6 @@ public IEnumerator TestConvertToHtml() Assert.IsNull(error); }, file: ms, - filename: "contract_A.pdf", model: "contracts", fileContentType: Utility.GetMimeType(Path.GetExtension(contractAFilepath)) ); diff --git a/Tests/CoreTests.cs b/Tests/CoreTests.cs index 4e821304b..9e802f149 100644 --- a/Tests/CoreTests.cs +++ b/Tests/CoreTests.cs @@ -18,6 +18,7 @@ using System.Collections; using System.Collections.Generic; using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; using IBM.Watson.Assistant.V1; using IBM.Watson.Assistant.V1.Model; using NUnit.Framework; @@ -53,7 +54,7 @@ public IEnumerator TestSetHeaders() service = new AssistantService(versionDate); } - while (!service.Credentials.HasIamTokenData()) + while (!service.Authenticator.CanAuthenticate()) yield return null; WorkspaceCollection listWorkspacesResponse = null; diff --git a/Tests/DiscoveryV1IntegrationTests.cs b/Tests/DiscoveryV1IntegrationTests.cs index d8abf2117..b37f38d4c 100644 --- a/Tests/DiscoveryV1IntegrationTests.cs +++ b/Tests/DiscoveryV1IntegrationTests.cs @@ -21,6 +21,7 @@ using System.IO; using System.Text; using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; using IBM.Cloud.SDK.Utilities; using IBM.Watson.Discovery.V1; using IBM.Watson.Discovery.V1.Model; @@ -89,7 +90,7 @@ public IEnumerator UnityTestSetup() service = new DiscoveryService(versionDate); } - while (!service.Credentials.HasIamTokenData()) + while (!service.Authenticator.CanAuthenticate()) yield return null; } @@ -888,8 +889,7 @@ public IEnumerator TestFederatedQuery() collectionIds: collectionId, passages: true, count: 10, - highlight: true, - loggingOptOut: true + highlight: true ); while (federatedQueryResponse == null) @@ -1408,9 +1408,9 @@ public IEnumerator TestQueryLog() } #endregion - #region CreateCredentials + #region CreateAuthenticator [UnityTest, Order(45)] - public IEnumerator TestCreateCredentials() + public IEnumerator TestCreateAuthenticator() { Log.Debug("DiscoveryServiceV1IntegrationTests", "Attempting to CreateCredentials..."); ModelCredentials createCredentialsResponse = null; diff --git a/Tests/LanguageTranslatorV3IntegrationTests.cs b/Tests/LanguageTranslatorV3IntegrationTests.cs index 12d035f5a..5a2aa3190 100644 --- a/Tests/LanguageTranslatorV3IntegrationTests.cs +++ b/Tests/LanguageTranslatorV3IntegrationTests.cs @@ -57,7 +57,7 @@ public IEnumerator UnityTestSetup() service = new LanguageTranslatorService(versionDate); } - while (!service.Credentials.HasIamTokenData()) + while (!service.Authenticator.CanAuthenticate()) yield return null; } @@ -81,7 +81,7 @@ public IEnumerator TestTranslate() Assert.IsNotNull(translateResponse); Assert.IsNotNull(translateResponse.Translations); Assert.IsTrue(translateResponse.Translations.Count > 0); - Assert.IsTrue(translateResponse.Translations[0].TranslationOutput == spanishText); + Assert.IsTrue(translateResponse.Translations[0]._Translation == spanishText); Assert.IsNull(error); }, text: new List() { englishText }, @@ -219,8 +219,7 @@ public IEnumerator TestListModels() Assert.IsNull(error); }, source: "en", - target: "fr", - defaultModels: true + target: "fr" ); while (listModelsResponse == null) diff --git a/Tests/NaturalLanguageClassifierV1IntegrationTests.cs b/Tests/NaturalLanguageClassifierV1IntegrationTests.cs index 91ff136cd..f6cb9edbc 100644 --- a/Tests/NaturalLanguageClassifierV1IntegrationTests.cs +++ b/Tests/NaturalLanguageClassifierV1IntegrationTests.cs @@ -19,6 +19,7 @@ using System.Collections.Generic; using System.IO; using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; using IBM.Watson.NaturalLanguageClassifier.V1; using IBM.Watson.NaturalLanguageClassifier.V1.Model; using NUnit.Framework; @@ -53,7 +54,7 @@ public IEnumerator UnityTestSetup() service = new NaturalLanguageClassifierService(); } - while (!service.Credentials.HasIamTokenData()) + while (!service.Authenticator.CanAuthenticate()) yield return null; } @@ -181,7 +182,7 @@ public IEnumerator TestCreateClassifier() Assert.IsTrue(createClassifierResponse.Language == "en"); Assert.IsNull(error); }, - metadata: ms0, + trainingMetadata: ms0, trainingData: ms1 ); diff --git a/Tests/NaturalLanguageUnderstandingV1IntegrationTests.cs b/Tests/NaturalLanguageUnderstandingV1IntegrationTests.cs index 74d5d0e26..cc3684942 100644 --- a/Tests/NaturalLanguageUnderstandingV1IntegrationTests.cs +++ b/Tests/NaturalLanguageUnderstandingV1IntegrationTests.cs @@ -18,6 +18,7 @@ using System.Collections; using System.Collections.Generic; using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; using IBM.Watson.NaturalLanguageUnderstanding.V1; using IBM.Watson.NaturalLanguageUnderstanding.V1.Model; using NUnit.Framework; @@ -46,7 +47,7 @@ public IEnumerator UnityTestSetup() service = new NaturalLanguageUnderstandingService(versionDate); } - while (!service.Credentials.HasIamTokenData()) + while (!service.Authenticator.CanAuthenticate()) yield return null; } diff --git a/Tests/PersonalityInsightsV3IntegrationTests.cs b/Tests/PersonalityInsightsV3IntegrationTests.cs index e1b3ba53e..c1104314b 100644 --- a/Tests/PersonalityInsightsV3IntegrationTests.cs +++ b/Tests/PersonalityInsightsV3IntegrationTests.cs @@ -19,6 +19,7 @@ using System.Collections.Generic; using System.IO; using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; using IBM.Watson.PersonalityInsights.V3; using IBM.Watson.PersonalityInsights.V3.Model; using NUnit.Framework; @@ -47,7 +48,7 @@ public IEnumerator UnityTestSetup() service = new PersonalityInsightsService(versionDate); } - while (!service.Credentials.HasIamTokenData()) + while (!service.Authenticator.CanAuthenticate()) yield return null; } diff --git a/Tests/SpeechToTextV1IntegrationTests.cs b/Tests/SpeechToTextV1IntegrationTests.cs index 30bd4032c..18cc29910 100644 --- a/Tests/SpeechToTextV1IntegrationTests.cs +++ b/Tests/SpeechToTextV1IntegrationTests.cs @@ -19,6 +19,7 @@ using System.Collections.Generic; using System.IO; using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; using IBM.Cloud.SDK.Utilities; using IBM.Watson.SpeechToText.V1; using IBM.Watson.SpeechToText.V1.Model; @@ -79,7 +80,7 @@ public IEnumerator UnityTestSetup() service = new SpeechToTextService(); } - while (!service.Credentials.HasIamTokenData()) + while (!service.Authenticator.CanAuthenticate()) yield return null; } @@ -461,7 +462,7 @@ public IEnumerator TestTrainLanguageModel() Log.Debug("SpeechToTextServiceV1IntegrationTests", "Attempting to TrainLanguageModel..."); object trainLanguageModelResponse = null; service.TrainLanguageModel( - callback: (DetailedResponse response, IBMError error) => + callback: (DetailedResponse response, IBMError error) => { Log.Debug("SpeechToTextServiceV1IntegrationTests", "TrainLanguageModel result: {0}", response.Response); trainLanguageModelResponse = response.Result; @@ -639,7 +640,7 @@ public IEnumerator TestTrainLanguageModel2() Log.Debug("SpeechToTextServiceV1IntegrationTests", "Attempting to TrainLanguageModel2..."); object trainLanguageModelResponse = null; service.TrainLanguageModel( - callback: (DetailedResponse response, IBMError error) => + callback: (DetailedResponse response, IBMError error) => { Log.Debug("SpeechToTextServiceV1IntegrationTests", "TrainLanguageModel result: {0}", response.Response); trainLanguageModelResponse = response.Result; @@ -763,7 +764,7 @@ public IEnumerator TestTrainLanguageModel3() Log.Debug("SpeechToTextServiceV1IntegrationTests", "Attempting to TrainLanguageModel3..."); object trainLanguageModelResponse = null; service.TrainLanguageModel( - callback: (DetailedResponse response, IBMError error) => + callback: (DetailedResponse response, IBMError error) => { Log.Debug("SpeechToTextServiceV1IntegrationTests", "TrainLanguageModel result: {0}", response.Response); trainLanguageModelResponse = response.Result; @@ -1012,7 +1013,7 @@ public IEnumerator TestTrainAcousticModel() Log.Debug("SpeechToTextServiceV1IntegrationTests", "Attempting to TrainAcousticModel..."); bool isComplete = false; service.TrainAcousticModel( - callback: (DetailedResponse response, IBMError error) => + callback: (DetailedResponse response, IBMError error) => { Log.Debug("SpeechToTextServiceV1IntegrationTests", "TrainAcousticModel result: {0}", response.Response); Assert.IsTrue(response.StatusCode == 200); diff --git a/Tests/TextToSpeechIntegrationTests.cs b/Tests/TextToSpeechIntegrationTests.cs index bdaf96470..714163dff 100644 --- a/Tests/TextToSpeechIntegrationTests.cs +++ b/Tests/TextToSpeechIntegrationTests.cs @@ -19,6 +19,7 @@ using System.Collections.Generic; using System.Text.RegularExpressions; using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; using IBM.Cloud.SDK.Utilities; using IBM.Watson.TextToSpeech.V1; using IBM.Watson.TextToSpeech.V1.Model; @@ -57,7 +58,7 @@ public IEnumerator UnityTestSetup() service = new TextToSpeechService(); } - while (!service.Credentials.HasIamTokenData()) + while (!service.Authenticator.CanAuthenticate()) yield return null; } diff --git a/Tests/ToneAnalyzerV3IntegrationTests.cs b/Tests/ToneAnalyzerV3IntegrationTests.cs index 6c9045396..6787f271d 100644 --- a/Tests/ToneAnalyzerV3IntegrationTests.cs +++ b/Tests/ToneAnalyzerV3IntegrationTests.cs @@ -18,6 +18,7 @@ using System.Collections; using System.Collections.Generic; using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; using IBM.Watson.ToneAnalyzer.V3; using IBM.Watson.ToneAnalyzer.V3.Model; using NUnit.Framework; @@ -46,7 +47,7 @@ public IEnumerator UnityTestSetup() service = new ToneAnalyzerService(versionDate); } - while (!service.Credentials.HasIamTokenData()) + while (!service.Authenticator.CanAuthenticate()) yield return null; } diff --git a/Tests/VisualRecognitionV3IntegrationTests.cs b/Tests/VisualRecognitionV3IntegrationTests.cs index 27a42ee8a..dc1aac9c6 100644 --- a/Tests/VisualRecognitionV3IntegrationTests.cs +++ b/Tests/VisualRecognitionV3IntegrationTests.cs @@ -20,6 +20,7 @@ using System.Collections.Generic; using System.IO; using IBM.Cloud.SDK; +using IBM.Cloud.SDK.Authentication; using IBM.Cloud.SDK.Utilities; using IBM.Watson.VisualRecognition.V3; using IBM.Watson.VisualRecognition.V3.Model; @@ -68,7 +69,7 @@ public IEnumerator UnityTestSetup() service = new VisualRecognitionService(versionDate); } - while (!service.Credentials.HasIamTokenData()) + while (!service.Authenticator.CanAuthenticate()) yield return null; } @@ -107,7 +108,7 @@ public IEnumerator TestCreateClassifier() Assert.IsTrue(createClassifierResponse.Name == classifierName); Assert.IsNotNull(createClassifierResponse.Classes); Assert.IsTrue(createClassifierResponse.Classes.Count > 0); - Assert.IsTrue(createClassifierResponse.Classes[0].ClassName == "giraffe"); + Assert.IsTrue(createClassifierResponse.Classes[0]._Class == "giraffe"); Assert.IsNull(error); }, name: classifierName, From 82b99f8867164ca23a9f4dc073d39e4dd869f5c6 Mon Sep 17 00:00:00 2001 From: Mamoon Raja Date: Thu, 29 Aug 2019 15:31:19 -0400 Subject: [PATCH 3/4] build: add meta files --- .gitignore | 2 +- .../Assistant/V1/Model/DialogSuggestionOutput.cs.meta | 11 +++++++++++ .../V1/Model/DialogSuggestionResponseGeneric.cs.meta | 11 +++++++++++ .../Assistant/V1/Model/RuntimeResponseGeneric.cs.meta | 11 +++++++++++ .../Assistant/V2/Model/RuntimeResponseGeneric.cs.meta | 11 +++++++++++ .../Services/Assistant/V2/Model/SearchResult.cs.meta | 11 +++++++++++ .../Assistant/V2/Model/SearchResultHighlight.cs.meta | 11 +++++++++++ .../Assistant/V2/Model/SearchResultMetadata.cs.meta | 11 +++++++++++ .../Services/CompareComply/V1/Model/Contexts.cs.meta | 11 +++++++++++ .../CompareComply/V1/Model/ContractCurrencies.cs.meta | 11 +++++++++++ .../CompareComply/V1/Model/ContractTerms.cs.meta | 11 +++++++++++ .../CompareComply/V1/Model/ContractTypes.cs.meta | 11 +++++++++++ .../CompareComply/V1/Model/Interpretation.cs.meta | 11 +++++++++++ .../Services/CompareComply/V1/Model/Mention.cs.meta | 11 +++++++++++ .../CompareComply/V1/Model/Paragraphs.cs.meta | 11 +++++++++++ .../CompareComply/V1/Model/PaymentTerms.cs.meta | 11 +++++++++++ .../CompareComply/V1/Model/TableTitle.cs.meta | 11 +++++++++++ .../V1/Model/SemanticRolesResultModelObject.cs.meta | 11 +++++++++++ .../SpeechToText/V1/Model/TrainingResponse.cs.meta | 11 +++++++++++ .../SpeechToText/V1/Model/TrainingWarning.cs.meta | 11 +++++++++++ 20 files changed, 210 insertions(+), 1 deletion(-) create mode 100644 Scripts/Services/Assistant/V1/Model/DialogSuggestionOutput.cs.meta create mode 100644 Scripts/Services/Assistant/V1/Model/DialogSuggestionResponseGeneric.cs.meta create mode 100644 Scripts/Services/Assistant/V1/Model/RuntimeResponseGeneric.cs.meta create mode 100644 Scripts/Services/Assistant/V2/Model/RuntimeResponseGeneric.cs.meta create mode 100644 Scripts/Services/Assistant/V2/Model/SearchResult.cs.meta create mode 100644 Scripts/Services/Assistant/V2/Model/SearchResultHighlight.cs.meta create mode 100644 Scripts/Services/Assistant/V2/Model/SearchResultMetadata.cs.meta create mode 100644 Scripts/Services/CompareComply/V1/Model/Contexts.cs.meta create mode 100644 Scripts/Services/CompareComply/V1/Model/ContractCurrencies.cs.meta create mode 100644 Scripts/Services/CompareComply/V1/Model/ContractTerms.cs.meta create mode 100644 Scripts/Services/CompareComply/V1/Model/ContractTypes.cs.meta create mode 100644 Scripts/Services/CompareComply/V1/Model/Interpretation.cs.meta create mode 100644 Scripts/Services/CompareComply/V1/Model/Mention.cs.meta create mode 100644 Scripts/Services/CompareComply/V1/Model/Paragraphs.cs.meta create mode 100644 Scripts/Services/CompareComply/V1/Model/PaymentTerms.cs.meta create mode 100644 Scripts/Services/CompareComply/V1/Model/TableTitle.cs.meta create mode 100644 Scripts/Services/NaturalLanguageUnderstanding/V1/Model/SemanticRolesResultModelObject.cs.meta create mode 100644 Scripts/Services/SpeechToText/V1/Model/TrainingResponse.cs.meta create mode 100644 Scripts/Services/SpeechToText/V1/Model/TrainingWarning.cs.meta diff --git a/.gitignore b/.gitignore index 1d1ff32bf..9164103cd 100644 --- a/.gitignore +++ b/.gitignore @@ -19,7 +19,7 @@ ExportedObj/ *.user *.unityproj *.booproj -*.meta + # ============ # # OS generated # # ============ # diff --git a/Scripts/Services/Assistant/V1/Model/DialogSuggestionOutput.cs.meta b/Scripts/Services/Assistant/V1/Model/DialogSuggestionOutput.cs.meta new file mode 100644 index 000000000..9207f1a0f --- /dev/null +++ b/Scripts/Services/Assistant/V1/Model/DialogSuggestionOutput.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bf80bc67f4c0449b4959b24d429662bf +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/Assistant/V1/Model/DialogSuggestionResponseGeneric.cs.meta b/Scripts/Services/Assistant/V1/Model/DialogSuggestionResponseGeneric.cs.meta new file mode 100644 index 000000000..f8ae6379e --- /dev/null +++ b/Scripts/Services/Assistant/V1/Model/DialogSuggestionResponseGeneric.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c0054016448a644018ad6cc11f1224cc +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/Assistant/V1/Model/RuntimeResponseGeneric.cs.meta b/Scripts/Services/Assistant/V1/Model/RuntimeResponseGeneric.cs.meta new file mode 100644 index 000000000..9be4c29ac --- /dev/null +++ b/Scripts/Services/Assistant/V1/Model/RuntimeResponseGeneric.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2417ec4b5b90340a38338e99ff548041 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/Assistant/V2/Model/RuntimeResponseGeneric.cs.meta b/Scripts/Services/Assistant/V2/Model/RuntimeResponseGeneric.cs.meta new file mode 100644 index 000000000..483e2a353 --- /dev/null +++ b/Scripts/Services/Assistant/V2/Model/RuntimeResponseGeneric.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9592b32c136e044bbb4519114e25bab9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/Assistant/V2/Model/SearchResult.cs.meta b/Scripts/Services/Assistant/V2/Model/SearchResult.cs.meta new file mode 100644 index 000000000..75ed65d1a --- /dev/null +++ b/Scripts/Services/Assistant/V2/Model/SearchResult.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5de7d26dd33a94d34b849f640e6ab3ad +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/Assistant/V2/Model/SearchResultHighlight.cs.meta b/Scripts/Services/Assistant/V2/Model/SearchResultHighlight.cs.meta new file mode 100644 index 000000000..573095dfe --- /dev/null +++ b/Scripts/Services/Assistant/V2/Model/SearchResultHighlight.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 34ed9a5dca0d54cfcbfb6af6c469a079 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/Assistant/V2/Model/SearchResultMetadata.cs.meta b/Scripts/Services/Assistant/V2/Model/SearchResultMetadata.cs.meta new file mode 100644 index 000000000..838fa5364 --- /dev/null +++ b/Scripts/Services/Assistant/V2/Model/SearchResultMetadata.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c613a90cc21a54182a85e788da1e2839 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/CompareComply/V1/Model/Contexts.cs.meta b/Scripts/Services/CompareComply/V1/Model/Contexts.cs.meta new file mode 100644 index 000000000..da872adcb --- /dev/null +++ b/Scripts/Services/CompareComply/V1/Model/Contexts.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 455d03913cfcd45788021fcac02533ab +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/CompareComply/V1/Model/ContractCurrencies.cs.meta b/Scripts/Services/CompareComply/V1/Model/ContractCurrencies.cs.meta new file mode 100644 index 000000000..ddbad6abd --- /dev/null +++ b/Scripts/Services/CompareComply/V1/Model/ContractCurrencies.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4682a2429680f48c9a42eb9502f77f3a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/CompareComply/V1/Model/ContractTerms.cs.meta b/Scripts/Services/CompareComply/V1/Model/ContractTerms.cs.meta new file mode 100644 index 000000000..99d502fdc --- /dev/null +++ b/Scripts/Services/CompareComply/V1/Model/ContractTerms.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a56d0df95350749668c595aeb120d4b3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/CompareComply/V1/Model/ContractTypes.cs.meta b/Scripts/Services/CompareComply/V1/Model/ContractTypes.cs.meta new file mode 100644 index 000000000..5331d38b0 --- /dev/null +++ b/Scripts/Services/CompareComply/V1/Model/ContractTypes.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c9c9375bb991540e8b164435765c7081 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/CompareComply/V1/Model/Interpretation.cs.meta b/Scripts/Services/CompareComply/V1/Model/Interpretation.cs.meta new file mode 100644 index 000000000..c5e611dcd --- /dev/null +++ b/Scripts/Services/CompareComply/V1/Model/Interpretation.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ef39af4f15bf5480da6cc0fe8a5cd895 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/CompareComply/V1/Model/Mention.cs.meta b/Scripts/Services/CompareComply/V1/Model/Mention.cs.meta new file mode 100644 index 000000000..261c7c116 --- /dev/null +++ b/Scripts/Services/CompareComply/V1/Model/Mention.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b0988f51de70842d8adc0bcc1d703a3e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/CompareComply/V1/Model/Paragraphs.cs.meta b/Scripts/Services/CompareComply/V1/Model/Paragraphs.cs.meta new file mode 100644 index 000000000..9a94e6eb3 --- /dev/null +++ b/Scripts/Services/CompareComply/V1/Model/Paragraphs.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f23ab7e851359416bbe058520f0f0ee1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/CompareComply/V1/Model/PaymentTerms.cs.meta b/Scripts/Services/CompareComply/V1/Model/PaymentTerms.cs.meta new file mode 100644 index 000000000..fb98777b8 --- /dev/null +++ b/Scripts/Services/CompareComply/V1/Model/PaymentTerms.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0942fa37e2c364725a324618c721fc87 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/CompareComply/V1/Model/TableTitle.cs.meta b/Scripts/Services/CompareComply/V1/Model/TableTitle.cs.meta new file mode 100644 index 000000000..8e497dc55 --- /dev/null +++ b/Scripts/Services/CompareComply/V1/Model/TableTitle.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 448d10d7423084fe7a37edb800c6adb1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/NaturalLanguageUnderstanding/V1/Model/SemanticRolesResultModelObject.cs.meta b/Scripts/Services/NaturalLanguageUnderstanding/V1/Model/SemanticRolesResultModelObject.cs.meta new file mode 100644 index 000000000..1e0a3069e --- /dev/null +++ b/Scripts/Services/NaturalLanguageUnderstanding/V1/Model/SemanticRolesResultModelObject.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 17e5eee8d262648128962e5e61f209ef +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/SpeechToText/V1/Model/TrainingResponse.cs.meta b/Scripts/Services/SpeechToText/V1/Model/TrainingResponse.cs.meta new file mode 100644 index 000000000..aef7e0f8f --- /dev/null +++ b/Scripts/Services/SpeechToText/V1/Model/TrainingResponse.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dcd99cb41561248b7a0690f67094891a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Services/SpeechToText/V1/Model/TrainingWarning.cs.meta b/Scripts/Services/SpeechToText/V1/Model/TrainingWarning.cs.meta new file mode 100644 index 000000000..aa02b9b15 --- /dev/null +++ b/Scripts/Services/SpeechToText/V1/Model/TrainingWarning.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 002cf191bd8b24cb48acb9d7d22c7012 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 9b81639cd075d30ab1146f2cec48a776ac114ae2 Mon Sep 17 00:00:00 2001 From: Mamoon Raja Date: Fri, 30 Aug 2019 10:21:29 -0400 Subject: [PATCH 4/4] docs: update bearer token example in readme --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2ee1e8d38..8a0156f01 100755 --- a/README.md +++ b/README.md @@ -136,8 +136,8 @@ string versionDate = ""; void TokenExample() { - // Create authenticator using the IAM apikey - authenticator = new IamAuthenticator(apikey: ""); + // Create authenticator using the Bearer Token + authenticator = new BearerTokenAuthenticator(""); assistant = new AssistantService(versionDate, authenticator); assistant.ListWorkspaces(callback: OnListWorkspaces); @@ -192,7 +192,7 @@ public IEnumerator ExampleAutoService() And that's it! -If you're using more than one service at a time in your code and get two different `ibm-authenticator.env` files, just put the contents together in one `ibm-authenticator.env` file and the SDK will handle assigning authenticator to their appropriate services. +If you're using more than one service at a time in your code and get two different `ibm-credentials.env` files, just put the contents together in one `ibm-credentials.env` file and the SDK will handle assigning authenticator to their appropriate services. If you would like to configure the location/name of your credential file, you can set an environment variable called `IBM_CREDENTIALS_FILE`. **This will take precedence over the locations specified above.** Here's how you can do that: