diff --git a/src/IBM.WatsonDeveloperCloud.Assistant.v1/AssistantService.cs b/src/IBM.WatsonDeveloperCloud.Assistant.v1/AssistantService.cs index 78767146a3..8e0646c68b 100644 --- a/src/IBM.WatsonDeveloperCloud.Assistant.v1/AssistantService.cs +++ b/src/IBM.WatsonDeveloperCloud.Assistant.v1/AssistantService.cs @@ -43,6 +43,7 @@ public AssistantService() : base(SERVICE_NAME, URL) this.Endpoint = URL; } + public AssistantService(string userName, string password, string versionDate) : this() { if (string.IsNullOrEmpty(userName)) @@ -57,6 +58,7 @@ public AssistantService(string userName, string password, string versionDate) : VersionDate = versionDate; } + public AssistantService(TokenOptions options, string versionDate) : this() { @@ -113,14 +115,14 @@ public MessageResponse Message(string workspaceId, MessageRequest request = null try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/workspaces/{workspaceId}/message"); @@ -166,14 +168,14 @@ public Workspace CreateWorkspace(CreateWorkspace properties = null, Dictionary try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.DeleteAsync($"{this.Endpoint}/v1/workspaces/{workspaceId}"); @@ -271,14 +273,14 @@ public WorkspaceExport GetWorkspace(string workspaceId, bool? export = null, boo try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/workspaces/{workspaceId}"); @@ -330,14 +332,14 @@ public WorkspaceCollection ListWorkspaces(long? pageLimit = null, bool? includeC try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/workspaces"); @@ -402,14 +404,14 @@ public Workspace UpdateWorkspace(string workspaceId, UpdateWorkspace properties try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/workspaces/{workspaceId}"); @@ -456,14 +458,14 @@ public Intent CreateIntent(string workspaceId, CreateIntent body, Dictionary cu try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.DeleteAsync($"{this.Endpoint}/v1/user_data"); diff --git a/src/IBM.WatsonDeveloperCloud.Assistant.v1/IBM.WatsonDeveloperCloud.Assistant.v1.csproj b/src/IBM.WatsonDeveloperCloud.Assistant.v1/IBM.WatsonDeveloperCloud.Assistant.v1.csproj index b976c52338..5898d2e5b7 100644 --- a/src/IBM.WatsonDeveloperCloud.Assistant.v1/IBM.WatsonDeveloperCloud.Assistant.v1.csproj +++ b/src/IBM.WatsonDeveloperCloud.Assistant.v1/IBM.WatsonDeveloperCloud.Assistant.v1.csproj @@ -15,16 +15,6 @@ 2.9.0 - - full - true - - - - full - true - - diff --git a/src/IBM.WatsonDeveloperCloud.Assistant.v1/Model/CreateDialogNode.cs b/src/IBM.WatsonDeveloperCloud.Assistant.v1/Model/CreateDialogNode.cs index 039a167be9..238feeaa8f 100644 --- a/src/IBM.WatsonDeveloperCloud.Assistant.v1/Model/CreateDialogNode.cs +++ b/src/IBM.WatsonDeveloperCloud.Assistant.v1/Model/CreateDialogNode.cs @@ -285,7 +285,7 @@ public enum DigressOutSlotsEnum /// [documentation](https://console.bluemix.net/docs/services/conversation/dialog-overview.html#complex). /// [JsonProperty("output", NullValueHandling = NullValueHandling.Ignore)] - public dynamic Output { get; set; } + public DialogNodeOutput Output { get; set; } /// /// The context for the dialog node. /// diff --git a/src/IBM.WatsonDeveloperCloud.Assistant.v1/Model/DialogNode.cs b/src/IBM.WatsonDeveloperCloud.Assistant.v1/Model/DialogNode.cs index d115292f52..31e62f7410 100644 --- a/src/IBM.WatsonDeveloperCloud.Assistant.v1/Model/DialogNode.cs +++ b/src/IBM.WatsonDeveloperCloud.Assistant.v1/Model/DialogNode.cs @@ -283,7 +283,7 @@ public enum DigressOutSlotsEnum /// [documentation](https://console.bluemix.net/docs/services/conversation/dialog-overview.html#complex). /// [JsonProperty("output", NullValueHandling = NullValueHandling.Ignore)] - public dynamic Output { get; set; } + public DialogNodeOutput Output { get; set; } /// /// The context (if defined) for the dialog node. /// diff --git a/src/IBM.WatsonDeveloperCloud.Assistant.v1/Model/DialogNodeOutputOptionsElementValue.cs b/src/IBM.WatsonDeveloperCloud.Assistant.v1/Model/DialogNodeOutputOptionsElementValue.cs index 0226b8c9b0..7deab7dd65 100644 --- a/src/IBM.WatsonDeveloperCloud.Assistant.v1/Model/DialogNodeOutputOptionsElementValue.cs +++ b/src/IBM.WatsonDeveloperCloud.Assistant.v1/Model/DialogNodeOutputOptionsElementValue.cs @@ -29,7 +29,7 @@ public class DialogNodeOutputOptionsElementValue : BaseModel /// The user input. /// [JsonProperty("input", NullValueHandling = NullValueHandling.Ignore)] - public dynamic Input { get; set; } + public InputData Input { get; set; } } } diff --git a/src/IBM.WatsonDeveloperCloud.Assistant.v1/Model/DialogSuggestionValue.cs b/src/IBM.WatsonDeveloperCloud.Assistant.v1/Model/DialogSuggestionValue.cs index 140224a05a..bfbc6c61b6 100644 --- a/src/IBM.WatsonDeveloperCloud.Assistant.v1/Model/DialogSuggestionValue.cs +++ b/src/IBM.WatsonDeveloperCloud.Assistant.v1/Model/DialogSuggestionValue.cs @@ -30,7 +30,7 @@ public class DialogSuggestionValue : BaseModel /// The user input. /// [JsonProperty("input", NullValueHandling = NullValueHandling.Ignore)] - public dynamic Input { get; set; } + public InputData Input { get; set; } /// /// An array of intents to be sent along with the user input. /// diff --git a/src/IBM.WatsonDeveloperCloud.Assistant.v1/Model/MessageRequest.cs b/src/IBM.WatsonDeveloperCloud.Assistant.v1/Model/MessageRequest.cs index 0b36e96116..0e1989af8a 100644 --- a/src/IBM.WatsonDeveloperCloud.Assistant.v1/Model/MessageRequest.cs +++ b/src/IBM.WatsonDeveloperCloud.Assistant.v1/Model/MessageRequest.cs @@ -29,7 +29,7 @@ public class MessageRequest : BaseModel /// An input object that includes the input text. /// [JsonProperty("input", NullValueHandling = NullValueHandling.Ignore)] - public dynamic Input { get; set; } + public InputData Input { get; set; } /// /// Whether to return more than one intent. Set to `true` to return all matching intents. /// @@ -40,7 +40,7 @@ public class MessageRequest : BaseModel /// previous response. /// [JsonProperty("context", NullValueHandling = NullValueHandling.Ignore)] - public dynamic Context { get; set; } + public Context Context { 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. @@ -58,7 +58,7 @@ public class MessageRequest : BaseModel /// multiple requests. /// [JsonProperty("output", NullValueHandling = NullValueHandling.Ignore)] - public dynamic Output { get; set; } + public OutputData Output { get; set; } } } diff --git a/src/IBM.WatsonDeveloperCloud.Assistant.v2/AssistantService.cs b/src/IBM.WatsonDeveloperCloud.Assistant.v2/AssistantService.cs index 8f867b35c7..b18c10168f 100644 --- a/src/IBM.WatsonDeveloperCloud.Assistant.v2/AssistantService.cs +++ b/src/IBM.WatsonDeveloperCloud.Assistant.v2/AssistantService.cs @@ -43,6 +43,7 @@ public AssistantService() : base(SERVICE_NAME, URL) this.Endpoint = URL; } + public AssistantService(string userName, string password, string versionDate) : this() { if (string.IsNullOrEmpty(userName)) @@ -57,6 +58,7 @@ public AssistantService(string userName, string password, string versionDate) : VersionDate = versionDate; } + public AssistantService(TokenOptions options, string versionDate) : this() { @@ -112,14 +114,14 @@ public SessionResponse CreateSession(string assistantId, Dictionary /// Unique identifier of the session. - /// The message to be sent. This includes the user's input, along with optional intents, - /// entities, and context from the last response. (optional) + /// The message to be sent. This includes the user's input, along with optional content + /// such as intents and entities. (optional) /// Custom data object to pass data including custom request headers. /// MessageResponse public MessageResponse Message(string assistantId, string sessionId, MessageRequest request = null, Dictionary customData = null) @@ -223,14 +225,14 @@ public MessageResponse Message(string assistantId, string sessionId, MessageRequ try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v2/assistants/{assistantId}/sessions/{sessionId}/message"); diff --git a/src/IBM.WatsonDeveloperCloud.Assistant.v2/IBM.WatsonDeveloperCloud.Assistant.v2.csproj b/src/IBM.WatsonDeveloperCloud.Assistant.v2/IBM.WatsonDeveloperCloud.Assistant.v2.csproj index 73a2da5e18..55486533b8 100644 --- a/src/IBM.WatsonDeveloperCloud.Assistant.v2/IBM.WatsonDeveloperCloud.Assistant.v2.csproj +++ b/src/IBM.WatsonDeveloperCloud.Assistant.v2/IBM.WatsonDeveloperCloud.Assistant.v2.csproj @@ -3,7 +3,7 @@ IBM.WatsonDeveloperCloud.Assistant.v2 wraps the Watson Developer Cloud Assistant service (http://www.ibm.com/watson/developercloud/assistant.html) IBM.WatsonDeveloperCloud.Assistant.v2 - 2.8.0 + 2.9.0 Watson Developer Cloud netstandard1.3 IBM.WatsonDeveloperCloud.Assistant.v2 @@ -12,7 +12,7 @@ https://watson-developer-cloud.github.io/dotnet-standard-sdk/img/Watson_Avatar_Pos_RGB.png https://github.com/watson-developer-cloud/dotnet-standard-sdk 1.6.0 - 2.8.0 + 2.9.0 diff --git a/src/IBM.WatsonDeveloperCloud.Assistant.v2/Model/MessageContext.cs b/src/IBM.WatsonDeveloperCloud.Assistant.v2/Model/MessageContext.cs index d8bc081204..5ddf4eb5d9 100644 --- a/src/IBM.WatsonDeveloperCloud.Assistant.v2/Model/MessageContext.cs +++ b/src/IBM.WatsonDeveloperCloud.Assistant.v2/Model/MessageContext.cs @@ -33,7 +33,7 @@ public class MessageContext : BaseModel /// Contains information specific to particular skills within the Assistant. /// [JsonProperty("skills", NullValueHandling = NullValueHandling.Ignore)] - public dynamic Skills { get; set; } + public MessageContextSkills Skills { get; set; } } } diff --git a/src/IBM.WatsonDeveloperCloud.Assistant.v2/Model/MessageContextGlobalSystem.cs b/src/IBM.WatsonDeveloperCloud.Assistant.v2/Model/MessageContextGlobalSystem.cs index c7fb1f5e28..2357ba0b7e 100644 --- a/src/IBM.WatsonDeveloperCloud.Assistant.v2/Model/MessageContextGlobalSystem.cs +++ b/src/IBM.WatsonDeveloperCloud.Assistant.v2/Model/MessageContextGlobalSystem.cs @@ -30,16 +30,15 @@ public class MessageContextGlobalSystem : BaseModel [JsonProperty("timezone", NullValueHandling = NullValueHandling.Ignore)] public string Timezone { get; set; } /// - /// String value provided by the API client that should be unique per each distinct end user of the service - /// powered by Assistant. + /// A string value that identifies the user who is interacting with the assistant. The client must provide a + /// unique identifier for each individual end user who accesses the application. This user ID may be used for + /// billing and other purposes. /// [JsonProperty("user_id", NullValueHandling = NullValueHandling.Ignore)] public string UserId { get; set; } /// - /// This property is normally set by the Assistant which sets this to 1 during the first conversation turn and - /// then increments it by 1 with every subsequent turn. A turn count equal to 0 (or > 0) informs the Assistant - /// that this is (or is not) the first turn in a conversation which influences the behavior of some skills. The - /// Conversation skill uses this to evaluate its `welcome` and `conversation_start` conditions. + /// A counter that is automatically incremented with each turn of the conversation. A value of 1 indicates that + /// this is the the first turn of a new conversation, which can affect the behavior of some skills. /// [JsonProperty("turn_count", NullValueHandling = NullValueHandling.Ignore)] public long? TurnCount { get; set; } diff --git a/src/IBM.WatsonDeveloperCloud.Conversation.v1/ConversationService.cs b/src/IBM.WatsonDeveloperCloud.Conversation.v1/ConversationService.cs index e82713abc1..f8e5a46e64 100644 --- a/src/IBM.WatsonDeveloperCloud.Conversation.v1/ConversationService.cs +++ b/src/IBM.WatsonDeveloperCloud.Conversation.v1/ConversationService.cs @@ -43,6 +43,7 @@ public ConversationService() : base(SERVICE_NAME, URL) this.Endpoint = URL; } + public ConversationService(string userName, string password, string versionDate) : this() { if (string.IsNullOrEmpty(userName)) @@ -57,6 +58,7 @@ public ConversationService(string userName, string password, string versionDate) VersionDate = versionDate; } + public ConversationService(TokenOptions options, string versionDate) : this() { @@ -113,14 +115,14 @@ public MessageResponse Message(string workspaceId, MessageRequest request = null try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/workspaces/{workspaceId}/message"); @@ -166,14 +168,14 @@ public Workspace CreateWorkspace(CreateWorkspace properties = null, Dictionary try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.DeleteAsync($"{this.Endpoint}/v1/workspaces/{workspaceId}"); @@ -271,14 +273,14 @@ public WorkspaceExport GetWorkspace(string workspaceId, bool? export = null, boo try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/workspaces/{workspaceId}"); @@ -330,14 +332,14 @@ public WorkspaceCollection ListWorkspaces(long? pageLimit = null, bool? includeC try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/workspaces"); @@ -402,14 +404,14 @@ public Workspace UpdateWorkspace(string workspaceId, UpdateWorkspace properties try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/workspaces/{workspaceId}"); @@ -456,14 +458,14 @@ public Intent CreateIntent(string workspaceId, CreateIntent body, Dictionary cu try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.DeleteAsync($"{this.Endpoint}/v1/user_data"); diff --git a/src/IBM.WatsonDeveloperCloud.Conversation.v1/IBM.WatsonDeveloperCloud.Conversation.v1.csproj b/src/IBM.WatsonDeveloperCloud.Conversation.v1/IBM.WatsonDeveloperCloud.Conversation.v1.csproj index b56819a5e5..7b708c0552 100644 --- a/src/IBM.WatsonDeveloperCloud.Conversation.v1/IBM.WatsonDeveloperCloud.Conversation.v1.csproj +++ b/src/IBM.WatsonDeveloperCloud.Conversation.v1/IBM.WatsonDeveloperCloud.Conversation.v1.csproj @@ -15,16 +15,6 @@ 2.9.0 - - full - true - - - - full - true - - diff --git a/src/IBM.WatsonDeveloperCloud.Conversation.v1/Model/CreateDialogNode.cs b/src/IBM.WatsonDeveloperCloud.Conversation.v1/Model/CreateDialogNode.cs index 49ed540ba4..449ed03e1c 100644 --- a/src/IBM.WatsonDeveloperCloud.Conversation.v1/Model/CreateDialogNode.cs +++ b/src/IBM.WatsonDeveloperCloud.Conversation.v1/Model/CreateDialogNode.cs @@ -285,7 +285,7 @@ public enum DigressOutSlotsEnum /// [documentation](https://console.bluemix.net/docs/services/conversation/dialog-overview.html#complex). /// [JsonProperty("output", NullValueHandling = NullValueHandling.Ignore)] - public dynamic Output { get; set; } + public DialogNodeOutput Output { get; set; } /// /// The context for the dialog node. /// diff --git a/src/IBM.WatsonDeveloperCloud.Conversation.v1/Model/DialogNode.cs b/src/IBM.WatsonDeveloperCloud.Conversation.v1/Model/DialogNode.cs index 0e815e5c50..8231152892 100644 --- a/src/IBM.WatsonDeveloperCloud.Conversation.v1/Model/DialogNode.cs +++ b/src/IBM.WatsonDeveloperCloud.Conversation.v1/Model/DialogNode.cs @@ -283,7 +283,7 @@ public enum DigressOutSlotsEnum /// [documentation](https://console.bluemix.net/docs/services/conversation/dialog-overview.html#complex). /// [JsonProperty("output", NullValueHandling = NullValueHandling.Ignore)] - public dynamic Output { get; set; } + public DialogNodeOutput Output { get; set; } /// /// The context (if defined) for the dialog node. /// diff --git a/src/IBM.WatsonDeveloperCloud.Conversation.v1/Model/DialogNodeOutputOptionsElementValue.cs b/src/IBM.WatsonDeveloperCloud.Conversation.v1/Model/DialogNodeOutputOptionsElementValue.cs index b5a4bbe776..b0558b7fa9 100644 --- a/src/IBM.WatsonDeveloperCloud.Conversation.v1/Model/DialogNodeOutputOptionsElementValue.cs +++ b/src/IBM.WatsonDeveloperCloud.Conversation.v1/Model/DialogNodeOutputOptionsElementValue.cs @@ -29,7 +29,7 @@ public class DialogNodeOutputOptionsElementValue : BaseModel /// The user input. /// [JsonProperty("input", NullValueHandling = NullValueHandling.Ignore)] - public dynamic Input { get; set; } + public InputData Input { get; set; } } } diff --git a/src/IBM.WatsonDeveloperCloud.Conversation.v1/Model/DialogSuggestionValue.cs b/src/IBM.WatsonDeveloperCloud.Conversation.v1/Model/DialogSuggestionValue.cs index b7bf95ae54..8660897ae5 100644 --- a/src/IBM.WatsonDeveloperCloud.Conversation.v1/Model/DialogSuggestionValue.cs +++ b/src/IBM.WatsonDeveloperCloud.Conversation.v1/Model/DialogSuggestionValue.cs @@ -30,7 +30,7 @@ public class DialogSuggestionValue : BaseModel /// The user input. /// [JsonProperty("input", NullValueHandling = NullValueHandling.Ignore)] - public dynamic Input { get; set; } + public InputData Input { get; set; } /// /// An array of intents to be sent along with the user input. /// diff --git a/src/IBM.WatsonDeveloperCloud.Conversation.v1/Model/MessageRequest.cs b/src/IBM.WatsonDeveloperCloud.Conversation.v1/Model/MessageRequest.cs index 18e854571a..b6002bd4ef 100644 --- a/src/IBM.WatsonDeveloperCloud.Conversation.v1/Model/MessageRequest.cs +++ b/src/IBM.WatsonDeveloperCloud.Conversation.v1/Model/MessageRequest.cs @@ -29,7 +29,7 @@ public class MessageRequest : BaseModel /// An input object that includes the input text. /// [JsonProperty("input", NullValueHandling = NullValueHandling.Ignore)] - public dynamic Input { get; set; } + public InputData Input { get; set; } /// /// Whether to return more than one intent. Set to `true` to return all matching intents. /// @@ -40,7 +40,7 @@ public class MessageRequest : BaseModel /// previous response. /// [JsonProperty("context", NullValueHandling = NullValueHandling.Ignore)] - public dynamic Context { get; set; } + public Context Context { 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. @@ -58,7 +58,7 @@ public class MessageRequest : BaseModel /// multiple requests. /// [JsonProperty("output", NullValueHandling = NullValueHandling.Ignore)] - public dynamic Output { get; set; } + public OutputData Output { get; set; } } } diff --git a/src/IBM.WatsonDeveloperCloud.Discovery.v1/DiscoveryService.cs b/src/IBM.WatsonDeveloperCloud.Discovery.v1/DiscoveryService.cs index 4cb228839d..4203a726b9 100644 --- a/src/IBM.WatsonDeveloperCloud.Discovery.v1/DiscoveryService.cs +++ b/src/IBM.WatsonDeveloperCloud.Discovery.v1/DiscoveryService.cs @@ -49,6 +49,7 @@ public DiscoveryService() : base(SERVICE_NAME, URL) this.Endpoint = URL; } + public DiscoveryService(string userName, string password, string versionDate) : this() { if (string.IsNullOrEmpty(userName)) @@ -63,6 +64,7 @@ public DiscoveryService(string userName, string password, string versionDate) : VersionDate = versionDate; } + public DiscoveryService(TokenOptions options, string versionDate) : this() { @@ -118,14 +120,14 @@ public Environment CreateEnvironment(CreateEnvironmentRequest body, Dictionary - /// Query documents in multiple collections. + /// Long environment queries. /// - /// See the [Discovery service documentation](https://console.bluemix.net/docs/services/discovery/using.html) - /// for more details. + /// Complex queries might be too long for a standard method query. By using this method, you can construct + /// longer queries. However, these queries may take longer to complete than the standard method. For details, + /// see the [Discovery service documentation](https://console.bluemix.net/docs/services/discovery/using.html). /// /// The ID of the environment. - /// A comma-separated list of collection IDs to be queried against. - /// A cacheable query that limits the documents returned to exclude any documents that - /// don't mention the query content. Filter searches are better for metadata type searches and when you are - /// trying to get a sense of concepts in the data set. (optional) - /// A query search returns all documents in your data set with full enrichments and full - /// text, but with the most relevant documents listed first. Use a query search when you want to find the most - /// relevant search results. You cannot use **natural_language_query** and **query** at the same time. - /// (optional) - /// A natural language query that returns relevant documents by utilizing - /// training data and natural language understanding. You cannot use **natural_language_query** and **query** at - /// the same time. (optional) - /// An aggregation search uses combinations of filters and query search to return an - /// exact answer. Aggregations are useful for building applications, because you can use them to build lists, - /// tables, and time series. For a full list of possible aggregrations, see the Query reference. - /// (optional) - /// Number of results to return. (optional, default to 10) - /// 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) - /// A comma separated list of fields in the document to sort on. You can optionally specify a - /// sort direction by prefixing the field with `-` for descending or `+` for ascending. Ascending is the default - /// sort direction if no prefix is specified. (optional) - /// When true a highlight field is returned for each result which contains the fields - /// that match the query with `` tags around the matching query terms. Defaults to false. - /// (optional) - /// When `true` and used with a Watson Discovery News collection, duplicate results - /// (based on the contents of the **title** field) are removed. Duplicate comparison is limited to the current - /// query only; **offset** is not considered. This parameter is currently Beta functionality. (optional, default - /// to false) - /// When specified, duplicate results based on the field specified are removed - /// from the returned results. Duplicate comparison is limited to the current query only, **offset** is not - /// considered. This parameter is currently Beta functionality. (optional) - /// When `true`, results are returned based on their similarity to the document IDs - /// specified in the **similar.document_ids** parameter. (optional, default to false) - /// A comma-separated list of document IDs that will be used to find similar - /// documents. - /// - /// **Note:** If the **natural_language_query** parameter is also specified, it will be used to expand the scope - /// of the document similarity search to include the natural language query. Other query parameters, such as - /// **filter** and **query** are subsequently applied and reduce the query scope. (optional) - /// A comma-separated list of field names that will be used as a basis for - /// comparison to identify similar documents. If not specified, the entire document is used for comparison. - /// (optional) - /// A passages query that returns the most relevant passages from the results. - /// (optional) - /// A comma-separated list of fields that passages are drawn from. If this - /// parameter not specified, then all top-level fields are included. (optional) - /// The maximum number of passages to return. The search returns fewer passages if - /// the requested total is not found. The default is `10`. The maximum is `100`. (optional) - /// The approximate number of characters that any one passage will have. The - /// default is `400`. The minimum is `50`. The maximum is `2000`. (optional) + /// An object that represents the query to be submitted. (optional) + /// If `true`, queries are not stored in the Discovery **Logs** endpoint. (optional, + /// default to false) /// Custom data object to pass data including custom request headers. /// QueryResponse - public QueryResponse FederatedQuery(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, bool? deduplicate = null, string deduplicateField = null, bool? similar = null, List similarDocumentIds = null, List similarFields = null, bool? passages = null, List passagesFields = null, long? passagesCount = null, long? passagesCharacters = null, Dictionary customData = null) + public QueryResponse FederatedQuery(string environmentId, QueryLarge queryLong = null, bool? loggingOptOut = null, Dictionary customData = null) { if (string.IsNullOrEmpty(environmentId)) throw new ArgumentNullException(nameof(environmentId)); - if (collectionIds == null) - throw new ArgumentNullException(nameof(collectionIds)); if(string.IsNullOrEmpty(VersionDate)) throw new ArgumentNullException("versionDate cannot be null."); @@ -1593,50 +1545,21 @@ public QueryResponse FederatedQuery(string environmentId, List collectio try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } - var restRequest = client.GetAsync($"{this.Endpoint}/v1/environments/{environmentId}/query"); + var restRequest = client.PostAsync($"{this.Endpoint}/v1/environments/{environmentId}/query"); restRequest.WithArgument("version", VersionDate); - restRequest.WithArgument("collection_ids", collectionIds != null && collectionIds.Count > 0 ? string.Join(",", collectionIds.ToArray()) : null); - if (!string.IsNullOrEmpty(filter)) - restRequest.WithArgument("filter", filter); - if (!string.IsNullOrEmpty(query)) - restRequest.WithArgument("query", query); - if (!string.IsNullOrEmpty(naturalLanguageQuery)) - restRequest.WithArgument("natural_language_query", naturalLanguageQuery); - if (!string.IsNullOrEmpty(aggregation)) - restRequest.WithArgument("aggregation", aggregation); - if (count != null) - restRequest.WithArgument("count", count); - restRequest.WithArgument("return", returnFields != null && returnFields.Count > 0 ? string.Join(",", returnFields.ToArray()) : null); - if (offset != null) - restRequest.WithArgument("offset", offset); - restRequest.WithArgument("sort", sort != null && sort.Count > 0 ? string.Join(",", sort.ToArray()) : null); - if (highlight != null) - restRequest.WithArgument("highlight", highlight); - if (deduplicate != null) - restRequest.WithArgument("deduplicate", deduplicate); - if (!string.IsNullOrEmpty(deduplicateField)) - restRequest.WithArgument("deduplicate.field", deduplicateField); - if (similar != null) - restRequest.WithArgument("similar", similar); - restRequest.WithArgument("similar.document_ids", similarDocumentIds != null && similarDocumentIds.Count > 0 ? string.Join(",", similarDocumentIds.ToArray()) : null); - restRequest.WithArgument("similar.fields", similarFields != null && similarFields.Count > 0 ? string.Join(",", similarFields.ToArray()) : null); - if (passages != null) - restRequest.WithArgument("passages", passages); - restRequest.WithArgument("passages.fields", passagesFields != null && passagesFields.Count > 0 ? string.Join(",", passagesFields.ToArray()) : null); - if (passagesCount != null) - restRequest.WithArgument("passages.count", passagesCount); - if (passagesCharacters != null) - restRequest.WithArgument("passages.characters", passagesCharacters); + if (loggingOptOut != null) + restRequest.WithHeader("X-Watson-Logging-Opt-Out", loggingOptOut.ToString()); + restRequest.WithBody(queryLong); if (customData != null) restRequest.WithCustomData(customData); result = restRequest.As().Result; @@ -1662,9 +1585,9 @@ public QueryResponse FederatedQuery(string environmentId, List collectio /// /// The ID of the environment. /// A comma-separated list of collection IDs to be queried against. - /// A cacheable query that limits the documents returned to exclude any documents that - /// don't mention the query content. Filter searches are better for metadata type searches and when you are - /// trying to get a sense of concepts in the data set. (optional) + /// A cacheable query that excludes documents that don't mention the query content. Filter + /// searches are better for metadata-type searches and for assessing the concepts in the data set. + /// (optional) /// A query search returns all documents in your data set with full enrichments and full /// text, but with the most relevant documents listed first. Use a query search when you want to find the most /// relevant search results. You cannot use **natural_language_query** and **query** at the same time. @@ -1672,35 +1595,32 @@ public QueryResponse FederatedQuery(string environmentId, List collectio /// A natural language query that returns relevant documents by utilizing /// training data and natural language understanding. You cannot use **natural_language_query** and **query** at /// the same time. (optional) - /// An aggregation search uses combinations of filters and query search to return an - /// exact answer. Aggregations are useful for building applications, because you can use them to build lists, - /// tables, and time series. For a full list of possible aggregrations, see the Query reference. - /// (optional) + /// An aggregation search that returns an exact answer by combining query search with + /// 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, default to 10) - /// 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) - /// A comma separated list of fields in the document to sort on. You can optionally specify a + /// of results that are returned is 10 and the offset is 8, it returns the last two results. (optional) + /// A comma-separated list of fields in the document to sort on. You can optionally specify a /// sort direction by prefixing the field with `-` for descending or `+` for ascending. Ascending is the default /// sort direction if no prefix is specified. (optional) - /// When true a highlight field is returned for each result which contains the fields - /// that match the query with `` tags around the matching query terms. Defaults to false. - /// (optional) + /// When true, a highlight field is returned for each result which contains the fields + /// which match the query with `` tags around the matching query terms. (optional, default to + /// false) /// When specified, duplicate results based on the field specified are removed /// from the returned results. Duplicate comparison is limited to the current query only, **offset** is not /// considered. This parameter is currently Beta functionality. (optional) /// When `true`, results are returned based on their similarity to the document IDs /// specified in the **similar.document_ids** parameter. (optional, default to false) - /// A comma-separated list of document IDs that will be used to find similar - /// documents. - /// - /// **Note:** If the **natural_language_query** parameter is also specified, it will be used to expand the scope - /// of the document similarity search to include the natural language query. Other query parameters, such as - /// **filter** and **query** are subsequently applied and reduce the query scope. (optional) - /// A comma-separated list of field names that will be used as a basis for - /// comparison to identify similar documents. If not specified, the entire document is used for comparison. - /// (optional) + /// A comma-separated list of document IDs to find similar documents. + /// + /// **Tip:** Include the **natural_language_query** parameter to expand the scope of the document similarity + /// search with the natural language query. Other query parameters, such as **filter** and **query**, are + /// subsequently applied and reduce the scope. (optional) + /// 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) /// Custom data object to pass data including custom request headers. /// QueryNoticesResponse public QueryNoticesResponse FederatedQueryNotices(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, Dictionary customData = null) @@ -1717,14 +1637,14 @@ public QueryNoticesResponse FederatedQueryNotices(string environmentId, List - /// Query your collection. + /// Long collection queries. /// - /// After your content is uploaded and enriched by the Discovery service, you can build queries to search your - /// content. For details, see the [Discovery service - /// documentation](https://console.bluemix.net/docs/services/discovery/using.html). + /// Complex queries might be too long for a standard method query. By using this method, you can construct + /// longer queries. However, these queries may take longer to complete than the standard method. For details, + /// see the [Discovery service documentation](https://console.bluemix.net/docs/services/discovery/using.html). /// /// The ID of the environment. /// The ID of the collection. - /// A cacheable query that limits the documents returned to exclude any documents that - /// don't mention the query content. Filter searches are better for metadata type searches and when you are - /// trying to get a sense of concepts in the data set. (optional) - /// A query search returns all documents in your data set with full enrichments and full - /// text, but with the most relevant documents listed first. Use a query search when you want to find the most - /// relevant search results. You cannot use **natural_language_query** and **query** at the same time. - /// (optional) - /// A natural language query that returns relevant documents by utilizing - /// training data and natural language understanding. You cannot use **natural_language_query** and **query** at - /// the same time. (optional) - /// A passages query that returns the most relevant passages from the results. - /// (optional) - /// An aggregation search uses combinations of filters and query search to return an - /// exact answer. Aggregations are useful for building applications, because you can use them to build lists, - /// tables, and time series. For a full list of possible aggregrations, see the Query reference. - /// (optional) - /// Number of results to return. (optional, default to 10) - /// 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) - /// A comma separated list of fields in the document to sort on. You can optionally specify a - /// sort direction by prefixing the field with `-` for descending or `+` for ascending. Ascending is the default - /// sort direction if no prefix is specified. (optional) - /// When true a highlight field is returned for each result which contains the fields - /// that match the query with `` tags around the matching query terms. Defaults to false. - /// (optional) - /// A comma-separated list of fields that passages are drawn from. If this - /// parameter not specified, then all top-level fields are included. (optional) - /// The maximum number of passages to return. The search returns fewer passages if - /// the requested total is not found. The default is `10`. The maximum is `100`. (optional) - /// The approximate number of characters that any one passage will have. The - /// default is `400`. The minimum is `50`. The maximum is `2000`. (optional) - /// When `true` and used with a Watson Discovery News collection, duplicate results - /// (based on the contents of the **title** field) are removed. Duplicate comparison is limited to the current - /// query only; **offset** is not considered. This parameter is currently Beta functionality. (optional, default - /// to false) - /// When specified, duplicate results based on the field specified are removed - /// from the returned results. Duplicate comparison is limited to the current query only, **offset** is not - /// considered. This parameter is currently Beta functionality. (optional) - /// When `true`, results are returned based on their similarity to the document IDs - /// specified in the **similar.document_ids** parameter. (optional, default to false) - /// A comma-separated list of document IDs that will be used to find similar - /// documents. - /// - /// **Note:** If the **natural_language_query** parameter is also specified, it will be used to expand the scope - /// of the document similarity search to include the natural language query. Other query parameters, such as - /// **filter** and **query** are subsequently applied and reduce the query scope. (optional) - /// A comma-separated list of field names that will be used as a basis for - /// comparison to identify similar documents. If not specified, the entire document is used for comparison. - /// (optional) + /// An object that represents the query to be submitted. (optional) /// If `true`, queries are not stored in the Discovery **Logs** endpoint. (optional, /// default to false) /// Custom data object to pass data including custom request headers. /// QueryResponse - public QueryResponse Query(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, bool? deduplicate = null, string deduplicateField = null, bool? similar = null, List similarDocumentIds = null, List similarFields = null, bool? loggingOptOut = null, Dictionary customData = null) + public QueryResponse Query(string environmentId, string collectionId, QueryLarge queryLong = null, bool? loggingOptOut = null, Dictionary customData = null) { if (string.IsNullOrEmpty(environmentId)) throw new ArgumentNullException(nameof(environmentId)); @@ -1845,51 +1715,21 @@ public QueryResponse Query(string environmentId, string collectionId, string fil try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } - var restRequest = client.GetAsync($"{this.Endpoint}/v1/environments/{environmentId}/collections/{collectionId}/query"); + var restRequest = client.PostAsync($"{this.Endpoint}/v1/environments/{environmentId}/collections/{collectionId}/query"); restRequest.WithArgument("version", VersionDate); if (loggingOptOut != null) restRequest.WithHeader("X-Watson-Logging-Opt-Out", loggingOptOut.ToString()); - if (!string.IsNullOrEmpty(filter)) - restRequest.WithArgument("filter", filter); - if (!string.IsNullOrEmpty(query)) - restRequest.WithArgument("query", query); - if (!string.IsNullOrEmpty(naturalLanguageQuery)) - restRequest.WithArgument("natural_language_query", naturalLanguageQuery); - if (passages != null) - restRequest.WithArgument("passages", passages); - if (!string.IsNullOrEmpty(aggregation)) - restRequest.WithArgument("aggregation", aggregation); - if (count != null) - restRequest.WithArgument("count", count); - restRequest.WithArgument("return", returnFields != null && returnFields.Count > 0 ? string.Join(",", returnFields.ToArray()) : null); - if (offset != null) - restRequest.WithArgument("offset", offset); - restRequest.WithArgument("sort", sort != null && sort.Count > 0 ? string.Join(",", sort.ToArray()) : null); - if (highlight != null) - restRequest.WithArgument("highlight", highlight); - restRequest.WithArgument("passages.fields", passagesFields != null && passagesFields.Count > 0 ? string.Join(",", passagesFields.ToArray()) : null); - if (passagesCount != null) - restRequest.WithArgument("passages.count", passagesCount); - if (passagesCharacters != null) - restRequest.WithArgument("passages.characters", passagesCharacters); - if (deduplicate != null) - restRequest.WithArgument("deduplicate", deduplicate); - if (!string.IsNullOrEmpty(deduplicateField)) - restRequest.WithArgument("deduplicate.field", deduplicateField); - if (similar != null) - restRequest.WithArgument("similar", similar); - restRequest.WithArgument("similar.document_ids", similarDocumentIds != null && similarDocumentIds.Count > 0 ? string.Join(",", similarDocumentIds.ToArray()) : null); - restRequest.WithArgument("similar.fields", similarFields != null && similarFields.Count > 0 ? string.Join(",", similarFields.ToArray()) : null); + restRequest.WithBody(queryLong); if (customData != null) restRequest.WithCustomData(customData); result = restRequest.As().Result; @@ -1933,14 +1773,14 @@ public QueryEntitiesResponse QueryEntities(string environmentId, string collecti try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/environments/{environmentId}/collections/{collectionId}/query_entities"); @@ -1971,9 +1811,9 @@ public QueryEntitiesResponse QueryEntities(string environmentId, string collecti /// /// The ID of the environment. /// The ID of the collection. - /// A cacheable query that limits the documents returned to exclude any documents that - /// don't mention the query content. Filter searches are better for metadata type searches and when you are - /// trying to get a sense of concepts in the data set. (optional) + /// A cacheable query that excludes documents that don't mention the query content. Filter + /// searches are better for metadata-type searches and for assessing the concepts in the data set. + /// (optional) /// A query search returns all documents in your data set with full enrichments and full /// text, but with the most relevant documents listed first. Use a query search when you want to find the most /// relevant search results. You cannot use **natural_language_query** and **query** at the same time. @@ -1983,41 +1823,38 @@ public QueryEntitiesResponse QueryEntities(string environmentId, string collecti /// the same time. (optional) /// A passages query that returns the most relevant passages from the results. /// (optional) - /// An aggregation search uses combinations of filters and query search to return an - /// exact answer. Aggregations are useful for building applications, because you can use them to build lists, - /// tables, and time series. For a full list of possible aggregrations, see the Query reference. - /// (optional) + /// An aggregation search that returns an exact answer by combining query search with + /// 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, default to 10) - /// 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) - /// A comma separated list of fields in the document to sort on. You can optionally specify a + /// of results that are returned is 10 and the offset is 8, it returns the last two results. (optional) + /// A comma-separated list of fields in the document to sort on. You can optionally specify a /// sort direction by prefixing the field with `-` for descending or `+` for ascending. Ascending is the default /// sort direction if no prefix is specified. (optional) - /// When true a highlight field is returned for each result which contains the fields - /// that match the query with `` tags around the matching query terms. Defaults to false. - /// (optional) + /// When true, a highlight field is returned for each result which contains the fields + /// which match the query with `` tags around the matching query terms. (optional, default to + /// false) /// A comma-separated list of fields that passages are drawn from. If this /// parameter not specified, then all top-level fields are included. (optional) /// The maximum number of passages to return. The search returns fewer passages if - /// the requested total is not found. The default is `10`. The maximum is `100`. (optional) - /// The approximate number of characters that any one passage will have. The - /// default is `400`. The minimum is `50`. The maximum is `2000`. (optional) + /// the requested total is not found. (optional, default to 10) + /// The approximate number of characters that any one passage will have. + /// (optional, default to 400) /// When specified, duplicate results based on the field specified are removed /// from the returned results. Duplicate comparison is limited to the current query only, **offset** is not /// considered. This parameter is currently Beta functionality. (optional) /// When `true`, results are returned based on their similarity to the document IDs /// specified in the **similar.document_ids** parameter. (optional, default to false) - /// A comma-separated list of document IDs that will be used to find similar - /// documents. - /// - /// **Note:** If the **natural_language_query** parameter is also specified, it will be used to expand the scope - /// of the document similarity search to include the natural language query. Other query parameters, such as - /// **filter** and **query** are subsequently applied and reduce the query scope. (optional) - /// A comma-separated list of field names that will be used as a basis for - /// comparison to identify similar documents. If not specified, the entire document is used for comparison. - /// (optional) + /// A comma-separated list of document IDs to find similar documents. + /// + /// **Tip:** Include the **natural_language_query** parameter to expand the scope of the document similarity + /// search with the natural language query. Other query parameters, such as **filter** and **query**, are + /// subsequently applied and reduce the scope. (optional) + /// 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) /// Custom data object to pass data including custom request headers. /// QueryNoticesResponse public QueryNoticesResponse QueryNotices(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, Dictionary customData = null) @@ -2034,14 +1871,14 @@ public QueryNoticesResponse QueryNotices(string environmentId, string collection try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/environments/{environmentId}/collections/{collectionId}/notices"); @@ -2118,14 +1955,14 @@ public QueryRelationsResponse QueryRelations(string environmentId, string collec try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/environments/{environmentId}/collections/{collectionId}/query_relations"); @@ -2173,14 +2010,14 @@ public TrainingQuery AddTrainingData(string environmentId, string collectionId, try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/environments/{environmentId}/collections/{collectionId}/training_data"); @@ -2230,14 +2067,14 @@ public TrainingExample CreateTrainingExample(string environmentId, string collec try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/environments/{environmentId}/collections/{collectionId}/training_data/{queryId}/examples"); @@ -2281,14 +2118,14 @@ public BaseModel DeleteAllTrainingData(string environmentId, string collectionId try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.DeleteAsync($"{this.Endpoint}/v1/environments/{environmentId}/collections/{collectionId}/training_data"); @@ -2334,14 +2171,14 @@ public BaseModel DeleteTrainingData(string environmentId, string collectionId, s try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.DeleteAsync($"{this.Endpoint}/v1/environments/{environmentId}/collections/{collectionId}/training_data/{queryId}"); @@ -2390,14 +2227,14 @@ public BaseModel DeleteTrainingExample(string environmentId, string collectionId try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.DeleteAsync($"{this.Endpoint}/v1/environments/{environmentId}/collections/{collectionId}/training_data/{queryId}/examples/{exampleId}"); @@ -2443,14 +2280,14 @@ public TrainingQuery GetTrainingData(string environmentId, string collectionId, try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/environments/{environmentId}/collections/{collectionId}/training_data/{queryId}"); @@ -2499,14 +2336,14 @@ public TrainingExample GetTrainingExample(string environmentId, string collectio try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/environments/{environmentId}/collections/{collectionId}/training_data/{queryId}/examples/{exampleId}"); @@ -2549,14 +2386,14 @@ public TrainingDataSet ListTrainingData(string environmentId, string collectionI try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/environments/{environmentId}/collections/{collectionId}/training_data"); @@ -2602,14 +2439,14 @@ public TrainingExampleList ListTrainingExamples(string environmentId, string col try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/environments/{environmentId}/collections/{collectionId}/training_data/{queryId}/examples"); @@ -2661,14 +2498,14 @@ public TrainingExample UpdateTrainingExample(string environmentId, string collec try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PutAsync($"{this.Endpoint}/v1/environments/{environmentId}/collections/{collectionId}/training_data/{queryId}/examples/{exampleId}"); @@ -2713,14 +2550,14 @@ public BaseModel DeleteUserData(string customerId, Dictionary cu try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.DeleteAsync($"{this.Endpoint}/v1/user_data"); @@ -2762,14 +2599,14 @@ public CreateEventResponse CreateEvent(CreateEventObject queryEvent, Dictionary< try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/events"); @@ -2804,7 +2641,7 @@ public CreateEventResponse CreateEvent(CreateEventObject queryEvent, Dictionary< /// The type of result to consider when calculating the metric. (optional) /// Custom data object to pass data including custom request headers. /// MetricResponse - public MetricResponse GetMetricsEventRate(DateTime? startTime = null, DateTime? endTime = null, string resultType = null, Dictionary customData = null) + public MetricResponse GetMetricsEventRate(DateTime startTime = null, DateTime endTime = null, string resultType = null, Dictionary customData = null) { if(string.IsNullOrEmpty(VersionDate)) @@ -2814,14 +2651,14 @@ public MetricResponse GetMetricsEventRate(DateTime? startTime = null, DateTime? try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/metrics/event_rate"); @@ -2859,7 +2696,7 @@ public MetricResponse GetMetricsEventRate(DateTime? startTime = null, DateTime? /// The type of result to consider when calculating the metric. (optional) /// Custom data object to pass data including custom request headers. /// MetricResponse - public MetricResponse GetMetricsQuery(DateTime? startTime = null, DateTime? endTime = null, string resultType = null, Dictionary customData = null) + public MetricResponse GetMetricsQuery(DateTime startTime = null, DateTime endTime = null, string resultType = null, Dictionary customData = null) { if(string.IsNullOrEmpty(VersionDate)) @@ -2869,14 +2706,14 @@ public MetricResponse GetMetricsQuery(DateTime? startTime = null, DateTime? endT try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/metrics/number_of_queries"); @@ -2916,7 +2753,7 @@ public MetricResponse GetMetricsQuery(DateTime? startTime = null, DateTime? endT /// The type of result to consider when calculating the metric. (optional) /// Custom data object to pass data including custom request headers. /// MetricResponse - public MetricResponse GetMetricsQueryEvent(DateTime? startTime = null, DateTime? endTime = null, string resultType = null, Dictionary customData = null) + public MetricResponse GetMetricsQueryEvent(DateTime startTime = null, DateTime endTime = null, string resultType = null, Dictionary customData = null) { if(string.IsNullOrEmpty(VersionDate)) @@ -2926,14 +2763,14 @@ public MetricResponse GetMetricsQueryEvent(DateTime? startTime = null, DateTime? try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/metrics/number_of_queries_with_event"); @@ -2972,7 +2809,7 @@ public MetricResponse GetMetricsQueryEvent(DateTime? startTime = null, DateTime? /// The type of result to consider when calculating the metric. (optional) /// Custom data object to pass data including custom request headers. /// MetricResponse - public MetricResponse GetMetricsQueryNoResults(DateTime? startTime = null, DateTime? endTime = null, string resultType = null, Dictionary customData = null) + public MetricResponse GetMetricsQueryNoResults(DateTime startTime = null, DateTime endTime = null, string resultType = null, Dictionary customData = null) { if(string.IsNullOrEmpty(VersionDate)) @@ -2982,14 +2819,14 @@ public MetricResponse GetMetricsQueryNoResults(DateTime? startTime = null, DateT try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/metrics/number_of_queries_with_no_search_results"); @@ -3035,14 +2872,14 @@ public MetricTokenResponse GetMetricsQueryTokenEvent(long? count = null, Diction try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/metrics/top_query_tokens_with_event_rate"); @@ -3070,17 +2907,17 @@ public MetricTokenResponse GetMetricsQueryTokenEvent(long? count = null, Diction /// Searches the query and event log to find query sessions that match the specified criteria. Searching the /// **logs** endpoint uses the standard Discovery query syntax for the parameters that are supported. /// - /// A cacheable query that limits the documents returned to exclude any documents that - /// don't mention the query content. Filter searches are better for metadata type searches and when you are - /// trying to get a sense of concepts in the data set. (optional) + /// A cacheable query that excludes documents that don't mention the query content. Filter + /// searches are better for metadata-type searches and for assessing the concepts in the data set. + /// (optional) /// A query search returns all documents in your data set with full enrichments and full /// text, but with the most relevant documents listed first. Use a query search when you want to find the most /// relevant search results. You cannot use **natural_language_query** and **query** at the same time. /// (optional) /// Number of results to return. (optional, default to 10) /// 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) - /// A comma separated list of fields in the document to sort on. You can optionally specify a + /// of results that are returned is 10 and the offset is 8, it returns the last two results. (optional) + /// A comma-separated list of fields in the document to sort on. You can optionally specify a /// sort direction by prefixing the field with `-` for descending or `+` for ascending. Ascending is the default /// sort direction if no prefix is specified. (optional) /// Custom data object to pass data including custom request headers. @@ -3095,14 +2932,14 @@ public LogQueryResponse QueryLog(string filter = null, string query = null, long try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/logs"); @@ -3156,14 +2993,14 @@ public Credentials CreateCredentials(string environmentId, Credentials credentia try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/environments/{environmentId}/credentials"); @@ -3207,14 +3044,14 @@ public DeleteCredentials DeleteCredentials(string environmentId, string credenti try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.DeleteAsync($"{this.Endpoint}/v1/environments/{environmentId}/credentials/{credentialId}"); @@ -3260,14 +3097,14 @@ public Credentials GetCredentials(string environmentId, string credentialId, Dic try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/environments/{environmentId}/credentials/{credentialId}"); @@ -3309,14 +3146,14 @@ public CredentialsList ListCredentials(string environmentId, Dictionary2.9.0 - - full - true - - - - full - true - - diff --git a/src/IBM.WatsonDeveloperCloud.Discovery.v1/IDiscoveryService.cs b/src/IBM.WatsonDeveloperCloud.Discovery.v1/IDiscoveryService.cs index fdf3f72b6e..e6c648966d 100644 --- a/src/IBM.WatsonDeveloperCloud.Discovery.v1/IDiscoveryService.cs +++ b/src/IBM.WatsonDeveloperCloud.Discovery.v1/IDiscoveryService.cs @@ -15,11 +15,9 @@ * */ -using System; using System.Collections.Generic; using System.Runtime.Serialization; using IBM.WatsonDeveloperCloud.Discovery.v1.Model; -using Environment = IBM.WatsonDeveloperCloud.Discovery.v1.Model.Environment; namespace IBM.WatsonDeveloperCloud.Discovery.v1 { @@ -50,9 +48,9 @@ public partial interface IDiscoveryService DeleteDocumentResponse DeleteDocument(string environmentId, string collectionId, string documentId, Dictionary customData = null); DocumentStatus GetDocumentStatus(string environmentId, string collectionId, string documentId, Dictionary customData = null); DocumentAccepted UpdateDocument(string environmentId, string collectionId, string documentId, System.IO.FileStream file = null, string metadata = null, string fileContentType = null, Dictionary customData = null); - QueryResponse FederatedQuery(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, bool? deduplicate = null, string deduplicateField = null, bool? similar = null, List similarDocumentIds = null, List similarFields = null, bool? passages = null, List passagesFields = null, long? passagesCount = null, long? passagesCharacters = null, Dictionary customData = null); + QueryResponse FederatedQuery(string environmentId, QueryLarge queryLong = null, bool? loggingOptOut = null, Dictionary customData = null); QueryNoticesResponse FederatedQueryNotices(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, Dictionary customData = null); - QueryResponse Query(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, bool? deduplicate = null, string deduplicateField = null, bool? similar = null, List similarDocumentIds = null, List similarFields = null, bool? loggingOptOut = null, Dictionary customData = null); + QueryResponse Query(string environmentId, string collectionId, QueryLarge queryLong = null, bool? loggingOptOut = null, Dictionary customData = null); QueryEntitiesResponse QueryEntities(string environmentId, string collectionId, QueryEntities entityQuery, Dictionary customData = null); QueryNoticesResponse QueryNotices(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, Dictionary customData = null); QueryRelationsResponse QueryRelations(string environmentId, string collectionId, QueryRelations relationshipQuery, Dictionary customData = null); @@ -68,10 +66,10 @@ public partial interface IDiscoveryService TrainingExample UpdateTrainingExample(string environmentId, string collectionId, string queryId, string exampleId, TrainingExamplePatch body, Dictionary customData = null); BaseModel DeleteUserData(string customerId, Dictionary customData = null); CreateEventResponse CreateEvent(CreateEventObject queryEvent, Dictionary customData = null); - MetricResponse GetMetricsEventRate(DateTime? startTime = null, DateTime? endTime = null, string resultType = null, Dictionary customData = null); - MetricResponse GetMetricsQuery(DateTime? startTime = null, DateTime? endTime = null, string resultType = null, Dictionary customData = null); - MetricResponse GetMetricsQueryEvent(DateTime? startTime = null, DateTime? endTime = null, string resultType = null, Dictionary customData = null); - MetricResponse GetMetricsQueryNoResults(DateTime? startTime = null, DateTime? endTime = null, string resultType = null, Dictionary customData = null); + MetricResponse GetMetricsEventRate(DateTime startTime = null, DateTime endTime = null, string resultType = null, Dictionary customData = null); + MetricResponse GetMetricsQuery(DateTime startTime = null, DateTime endTime = null, string resultType = null, Dictionary customData = null); + MetricResponse GetMetricsQueryEvent(DateTime startTime = null, DateTime endTime = null, string resultType = null, Dictionary customData = null); + MetricResponse GetMetricsQueryNoResults(DateTime startTime = null, DateTime endTime = null, string resultType = null, Dictionary customData = null); MetricTokenResponse GetMetricsQueryTokenEvent(long? count = null, Dictionary customData = null); LogQueryResponse QueryLog(string filter = null, string query = null, long? count = null, long? offset = null, List sort = null, Dictionary customData = null); Credentials CreateCredentials(string environmentId, Credentials credentialsParameter, Dictionary customData = null); diff --git a/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/CreateEnvironmentRequest.cs b/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/CreateEnvironmentRequest.cs index 8859dfd909..a5da0be137 100644 --- a/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/CreateEnvironmentRequest.cs +++ b/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/CreateEnvironmentRequest.cs @@ -15,7 +15,6 @@ * */ -using System; using System.Runtime.Serialization; using Newtonsoft.Json; using Newtonsoft.Json.Converters; @@ -28,15 +27,23 @@ namespace IBM.WatsonDeveloperCloud.Discovery.v1.Model public class CreateEnvironmentRequest : BaseModel { /// - /// Size of the environment. + /// Size of the environment. In the Lite plan the default and only accepted value is `LT`, in all other plans + /// the default is `S`. /// /// - /// Size of the environment. + /// Size of the environment. In the Lite plan the default and only accepted value is `LT`, in all other plans + /// the default is `S`. /// [JsonConverter(typeof(StringEnumConverter))] public enum SizeEnum { + /// + /// Enum LT for LT + /// + [EnumMember(Value = "LT")] + LT, + /// /// Enum XS for XS /// @@ -90,41 +97,14 @@ public enum SizeEnum /// [EnumMember(Value = "XXXL")] XXXL - } - + } + /// - /// Size of the environment. + /// Size of the environment. In the Lite plan the default and only accepted value is `LT`, in all other plans + /// the default is `S`. /// - [Obsolete("Integer size is deprecated. Please use StringSize.")] - public long? Size - { - get - { - int size; - int.TryParse(_convertedSize, out size); - return size; - } - set { _convertedSize = value.ToString(); } - } - /// - /// Size of the environment. - /// - public SizeEnum? StringSize - { - get - { - SizeEnum size; - Enum.TryParse(_convertedSize, out size); - return size; - } - set { _convertedSize = value.ToString(); } - } - /// - /// Size of the environment - /// - [JsonProperty("size", NullValueHandling = NullValueHandling.Ignore)] - private string _convertedSize; - + [JsonProperty("size", NullValueHandling = NullValueHandling.Ignore)] + public SizeEnum? Size { get; set; } /// /// Name that identifies the environment. /// diff --git a/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/Environment.cs b/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/Environment.cs index 794f3c052a..7d67a0f94c 100644 --- a/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/Environment.cs +++ b/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/Environment.cs @@ -28,10 +28,12 @@ namespace IBM.WatsonDeveloperCloud.Discovery.v1.Model public class Environment : BaseModel { /// - /// Status of the environment. + /// Current status of the environment. `resizing` is displayed when a request to increase the environment size + /// has been made, but is still in the process of being completed. /// /// - /// Status of the environment. + /// Current status of the environment. `resizing` is displayed when a request to increase the environment size + /// has been made, but is still in the process of being completed. /// [JsonConverter(typeof(StringEnumConverter))] public enum StatusEnum @@ -53,19 +55,31 @@ public enum StatusEnum /// Enum MAINTENANCE for maintenance /// [EnumMember(Value = "maintenance")] - MAINTENANCE + MAINTENANCE, + + /// + /// Enum RESIZING for resizing + /// + [EnumMember(Value = "resizing")] + RESIZING } /// - /// Size of the environment. + /// Current size of the environment. /// /// - /// Size of the environment. + /// Current size of the environment. /// [JsonConverter(typeof(StringEnumConverter))] public enum SizeEnum { + /// + /// Enum LT for LT + /// + [EnumMember(Value = "LT")] + LT, + /// /// Enum XS for XS /// @@ -122,43 +136,16 @@ public enum SizeEnum } /// - /// Status of the environment. + /// Current status of the environment. `resizing` is displayed when a request to increase the environment size + /// has been made, but is still in the process of being completed. /// [JsonProperty("status", NullValueHandling = NullValueHandling.Ignore)] - public StatusEnum? Status { get; set; } + public StatusEnum? Status { get; set; } /// - /// Size of the environment. + /// Current size of the environment. /// - [Obsolete("Integer size is deprecated. Please use StringSize.")] - public long? Size - { - get - { - int size; - int.TryParse(_convertedSize, out size); - return size; - } - set { _convertedSize = value.ToString(); } - } - /// - /// Size of the environment. - /// - public SizeEnum? StringSize - { - get - { - SizeEnum size; - Enum.TryParse(_convertedSize, out size); - return size; - } - set { _convertedSize = value.ToString(); } - } - /// - /// Size of the environment - /// - [JsonProperty("size", NullValueHandling = NullValueHandling.Ignore)] - private string _convertedSize; - + [JsonProperty("size", NullValueHandling = NullValueHandling.Ignore)] + public SizeEnum? Size { get; set; } /// /// Unique identifier for the environment. /// @@ -190,10 +177,22 @@ public SizeEnum? StringSize [JsonProperty("read_only", NullValueHandling = NullValueHandling.Ignore)] public virtual bool? _ReadOnly { get; private set; } /// + /// The new size requested for this environment. Only returned when the environment *status* is `resizing`. + /// + /// *Note:* Querying and indexing can still be performed during an environment upsize. + /// + [JsonProperty("requested_size", NullValueHandling = NullValueHandling.Ignore)] + public string RequestedSize { get; set; } + /// /// Details about the resource usage and capacity of the environment. /// [JsonProperty("index_capacity", NullValueHandling = NullValueHandling.Ignore)] public IndexCapacity IndexCapacity { get; set; } + /// + /// Information about Continuous Relevancy Training for this environment. + /// + [JsonProperty("search_status", NullValueHandling = NullValueHandling.Ignore)] + public SearchStatus SearchStatus { get; set; } } } diff --git a/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/EventData.cs b/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/EventData.cs index 17b9a4af5c..bab64b8327 100644 --- a/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/EventData.cs +++ b/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/EventData.cs @@ -40,7 +40,7 @@ public class EventData : BaseModel /// in the log was used. /// [JsonProperty("client_timestamp", NullValueHandling = NullValueHandling.Ignore)] - public DateTime? ClientTimestamp { get; set; } + public DateTime ClientTimestamp { get; set; } /// /// The rank of the result item which the event is associated with. /// diff --git a/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/LogQueryResponseResult.cs b/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/LogQueryResponseResult.cs index 9c6ca8aa35..9cce8c5fc2 100644 --- a/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/LogQueryResponseResult.cs +++ b/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/LogQueryResponseResult.cs @@ -163,13 +163,13 @@ public enum ResultTypeEnum /// Date that the log result was created. Returned in `YYYY-MM-DDThh:mm:ssZ` format. /// [JsonProperty("created_timestamp", NullValueHandling = NullValueHandling.Ignore)] - public DateTime? CreatedTimestamp { get; set; } + public DateTime CreatedTimestamp { get; set; } /// /// Date specified by the user when recording an event. Returned in `YYYY-MM-DDThh:mm:ssZ` format. Only returned /// with logs of type **event**. /// [JsonProperty("client_timestamp", NullValueHandling = NullValueHandling.Ignore)] - public DateTime? ClientTimestamp { get; set; } + public DateTime ClientTimestamp { get; set; } /// /// Identifier that corresponds to the **natural_language_query** string used in the original or associated /// query. All **event** and **query** log entries that have the same original **natural_language_query** string diff --git a/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/MetricAggregationResult.cs b/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/MetricAggregationResult.cs index 616f0b9426..1db2404d30 100644 --- a/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/MetricAggregationResult.cs +++ b/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/MetricAggregationResult.cs @@ -29,7 +29,7 @@ public class MetricAggregationResult : BaseModel /// Date in string form representing the start of this interval. /// [JsonProperty("key_as_string", NullValueHandling = NullValueHandling.Ignore)] - public DateTime? KeyAsString { get; set; } + public DateTime KeyAsString { get; set; } /// /// Unix epoch time equivalent of the **key_as_string**, that represents the start of this interval. /// diff --git a/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/QueryLarge.cs b/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/QueryLarge.cs new file mode 100644 index 0000000000..6e01e91785 --- /dev/null +++ b/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/QueryLarge.cs @@ -0,0 +1,156 @@ +/** +* Copyright 2018 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.WatsonDeveloperCloud.Discovery.v1.Model +{ + /// + /// Object that describes a long query. + /// + public class QueryLarge : BaseModel + { + /// + /// A cacheable query that excludes documents that don't mention the query content. Filter searches are better + /// for metadata-type searches and for assessing the concepts in the data set. + /// + [JsonProperty("filter", NullValueHandling = NullValueHandling.Ignore)] + public string Filter { get; set; } + /// + /// A query search returns all documents in your data set with full enrichments and full text, but with the most + /// relevant documents listed first. Use a query search when you want to find the most relevant search results. + /// You cannot use **natural_language_query** and **query** at the same time. + /// + [JsonProperty("query", NullValueHandling = NullValueHandling.Ignore)] + public string Query { get; set; } + /// + /// A natural language query that returns relevant documents by utilizing training data and natural language + /// understanding. You cannot use **natural_language_query** and **query** at the same time. + /// + [JsonProperty("natural_language_query", NullValueHandling = NullValueHandling.Ignore)] + public string NaturalLanguageQuery { get; set; } + /// + /// A passages query that returns the most relevant passages from the results. + /// + [JsonProperty("passages", NullValueHandling = NullValueHandling.Ignore)] + public bool? Passages { get; set; } + /// + /// An aggregation search that returns an exact answer by combining query search with filters. Useful for + /// applications to build lists, tables, and time series. For a full list of possible aggregations, see the + /// Query reference. + /// + [JsonProperty("aggregation", NullValueHandling = NullValueHandling.Ignore)] + public string Aggregation { get; set; } + /// + /// Number of results to return. + /// + [JsonProperty("count", NullValueHandling = NullValueHandling.Ignore)] + public long? Count { get; set; } + /// + /// A comma-separated list of the portion of the document hierarchy to return. + /// + [JsonProperty("return", NullValueHandling = NullValueHandling.Ignore)] + public List ReturnFields { get; set; } + /// + /// 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. + /// + [JsonProperty("offset", NullValueHandling = NullValueHandling.Ignore)] + public long? Offset { get; set; } + /// + /// A comma-separated list of fields in the document to sort on. You can optionally specify a sort direction by + /// prefixing the field with `-` for descending or `+` for ascending. Ascending is the default sort direction if + /// no prefix is specified. This parameter cannot be used in the same query as the **bias** parameter. + /// + [JsonProperty("sort", NullValueHandling = NullValueHandling.Ignore)] + public List Sort { get; set; } + /// + /// When true, a highlight field is returned for each result which contains the fields which match the query + /// with `` tags around the matching query terms. + /// + [JsonProperty("highlight", NullValueHandling = NullValueHandling.Ignore)] + public bool? Highlight { get; set; } + /// + /// A comma-separated list of fields that passages are drawn from. If this parameter not specified, then all + /// top-level fields are included. + /// + [JsonProperty("passages.fields", NullValueHandling = NullValueHandling.Ignore)] + public List PassagesFields { get; set; } + /// + /// The maximum number of passages to return. The search returns fewer passages if the requested total is not + /// found. The default is `10`. The maximum is `100`. + /// + [JsonProperty("passages.count", NullValueHandling = NullValueHandling.Ignore)] + public long? PassagesCount { get; set; } + /// + /// The approximate number of characters that any one passage will have. + /// + [JsonProperty("passages.characters", NullValueHandling = NullValueHandling.Ignore)] + public long? PassagesCharacters { get; set; } + /// + /// When `true` and used with a Watson Discovery News collection, duplicate results (based on the contents of + /// the **title** field) are removed. Duplicate comparison is limited to the current query only; **offset** is + /// not considered. This parameter is currently Beta functionality. + /// + [JsonProperty("deduplicate", NullValueHandling = NullValueHandling.Ignore)] + public bool? Deduplicate { get; set; } + /// + /// When specified, duplicate results based on the field specified are removed from the returned results. + /// Duplicate comparison is limited to the current query only, **offset** is not considered. This parameter is + /// currently Beta functionality. + /// + [JsonProperty("deduplicate.field", NullValueHandling = NullValueHandling.Ignore)] + public string DeduplicateField { get; set; } + /// + /// A comma-separated list of collection IDs to be queried against. Required when querying multiple collections, + /// invalid when performing a single collection query. + /// + [JsonProperty("collection_ids", NullValueHandling = NullValueHandling.Ignore)] + public List CollectionIds { get; set; } + /// + /// When `true`, results are returned based on their similarity to the document IDs specified in the + /// **similar.document_ids** parameter. + /// + [JsonProperty("similar", NullValueHandling = NullValueHandling.Ignore)] + public bool? Similar { get; set; } + /// + /// A comma-separated list of document IDs to find similar documents. + /// + /// **Tip:** Include the **natural_language_query** parameter to expand the scope of the document similarity + /// search with the natural language query. Other query parameters, such as **filter** and **query**, are + /// subsequently applied and reduce the scope. + /// + [JsonProperty("similar.document_ids", NullValueHandling = NullValueHandling.Ignore)] + public List SimilarDocumentIds { get; set; } + /// + /// 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. + /// + [JsonProperty("similar.fields", NullValueHandling = NullValueHandling.Ignore)] + public List SimilarFields { get; set; } + /// + /// Field which the returned results will be biased against. The specified field must be either a **date** or + /// **number** format. When a **date** type field is specified returned results are biased 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. + /// + [JsonProperty("bias", NullValueHandling = NullValueHandling.Ignore)] + public string Bias { get; set; } + } + +} diff --git a/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/QueryRelations.cs b/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/QueryRelations.cs index e77965e1c8..9ed3dbfcdc 100644 --- a/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/QueryRelations.cs +++ b/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/QueryRelations.cs @@ -29,11 +29,13 @@ public class QueryRelations : BaseModel { /// /// The sorting method for the relationships, can be `score` or `frequency`. `frequency` is the number of unique - /// times each entity is identified. The default is `score`. + /// times each entity is identified. The default is `score`. This parameter cannot be used in the same query as + /// the **bias** parameter. /// /// /// The sorting method for the relationships, can be `score` or `frequency`. `frequency` is the number of unique - /// times each entity is identified. The default is `score`. + /// times each entity is identified. The default is `score`. This parameter cannot be used in the same query as + /// the **bias** parameter. /// [JsonConverter(typeof(StringEnumConverter))] public enum SortEnum @@ -54,7 +56,8 @@ public enum SortEnum /// /// The sorting method for the relationships, can be `score` or `frequency`. `frequency` is the number of unique - /// times each entity is identified. The default is `score`. + /// times each entity is identified. The default is `score`. This parameter cannot be used in the same query as + /// the **bias** parameter. /// [JsonProperty("sort", NullValueHandling = NullValueHandling.Ignore)] public SortEnum? Sort { get; set; } diff --git a/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/SearchStatus.cs b/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/SearchStatus.cs new file mode 100644 index 0000000000..ac639da571 --- /dev/null +++ b/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/SearchStatus.cs @@ -0,0 +1,92 @@ +/** +* Copyright 2018 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.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace IBM.WatsonDeveloperCloud.Discovery.v1.Model +{ + /// + /// Information about the Continuous Relevancy Training for this environment. + /// + public class SearchStatus : BaseModel + { + /// + /// The current status of Continuous Relevancy Training for this environment. + /// + /// + /// The current status of Continuous Relevancy Training for this environment. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum StatusEnum + { + + /// + /// Enum NO_DATA for NO_DATA + /// + [EnumMember(Value = "NO_DATA")] + NO_DATA, + + /// + /// Enum INSUFFICENT_DATA for INSUFFICENT_DATA + /// + [EnumMember(Value = "INSUFFICENT_DATA")] + INSUFFICENT_DATA, + + /// + /// Enum TRAINING for TRAINING + /// + [EnumMember(Value = "TRAINING")] + TRAINING, + + /// + /// Enum TRAINED for TRAINED + /// + [EnumMember(Value = "TRAINED")] + TRAINED, + + /// + /// Enum NOT_APPLICABLE for NOT_APPLICABLE + /// + [EnumMember(Value = "NOT_APPLICABLE")] + NOT_APPLICABLE + } + + /// + /// The current status of Continuous Relevancy Training for this environment. + /// + [JsonProperty("status", NullValueHandling = NullValueHandling.Ignore)] + public StatusEnum? Status { get; set; } + /// + /// Current scope of the training. Always returned as `environment`. + /// + [JsonProperty("scope", NullValueHandling = NullValueHandling.Ignore)] + public string Scope { get; set; } + /// + /// Long description of the current Continuous Relevancy Training status. + /// + [JsonProperty("status_description", NullValueHandling = NullValueHandling.Ignore)] + public string StatusDescription { get; set; } + /// + /// The date stamp of the most recent completed training for this environment. + /// + [JsonProperty("last_trained", NullValueHandling = NullValueHandling.Ignore)] + public DateTime? LastTrained { get; set; } + } + +} diff --git a/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/SourceStatus.cs b/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/SourceStatus.cs index 94728adc54..f3395d411c 100644 --- a/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/SourceStatus.cs +++ b/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/SourceStatus.cs @@ -98,7 +98,7 @@ public enum StatusEnum /// Date in UTC format indicating when the last crawl was attempted. If `null`, no crawl was completed. /// [JsonProperty("last_updated", NullValueHandling = NullValueHandling.Ignore)] - public DateTime? LastUpdated { get; set; } + public DateTime LastUpdated { get; set; } } } diff --git a/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/TrainingStatus.cs b/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/TrainingStatus.cs index 3acc363757..6f8a77d947 100644 --- a/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/TrainingStatus.cs +++ b/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/TrainingStatus.cs @@ -64,12 +64,12 @@ public class TrainingStatus : BaseModel /// Gets or Sets SuccessfullyTrained /// [JsonProperty("successfully_trained", NullValueHandling = NullValueHandling.Ignore)] - public DateTime? SuccessfullyTrained { get; set; } + public DateTime SuccessfullyTrained { get; set; } /// /// Gets or Sets DataUpdated /// [JsonProperty("data_updated", NullValueHandling = NullValueHandling.Ignore)] - public DateTime? DataUpdated { get; set; } + public DateTime DataUpdated { get; set; } } } diff --git a/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/UpdateEnvironmentRequest.cs b/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/UpdateEnvironmentRequest.cs index 9bc56ffe7a..f05a5a0c75 100644 --- a/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/UpdateEnvironmentRequest.cs +++ b/src/IBM.WatsonDeveloperCloud.Discovery.v1/Model/UpdateEnvironmentRequest.cs @@ -15,7 +15,9 @@ * */ +using System.Runtime.Serialization; using Newtonsoft.Json; +using Newtonsoft.Json.Converters; namespace IBM.WatsonDeveloperCloud.Discovery.v1.Model { @@ -24,6 +26,73 @@ namespace IBM.WatsonDeveloperCloud.Discovery.v1.Model /// public class UpdateEnvironmentRequest : BaseModel { + /// + /// Size that the environment should be increased to. Environment size cannot be modified when using a Lite + /// plan. Environment size can only increased and not decreased. + /// + /// + /// Size that the environment should be increased to. Environment size cannot be modified when using a Lite + /// plan. Environment size can only increased and not decreased. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum SizeEnum + { + + /// + /// Enum S for S + /// + [EnumMember(Value = "S")] + S, + + /// + /// Enum MS for MS + /// + [EnumMember(Value = "MS")] + MS, + + /// + /// Enum M for M + /// + [EnumMember(Value = "M")] + M, + + /// + /// Enum ML for ML + /// + [EnumMember(Value = "ML")] + ML, + + /// + /// Enum L for L + /// + [EnumMember(Value = "L")] + L, + + /// + /// Enum XL for XL + /// + [EnumMember(Value = "XL")] + XL, + + /// + /// Enum XXL for XXL + /// + [EnumMember(Value = "XXL")] + XXL, + + /// + /// Enum XXXL for XXXL + /// + [EnumMember(Value = "XXXL")] + XXXL + } + + /// + /// Size that the environment should be increased to. Environment size cannot be modified when using a Lite + /// plan. Environment size can only increased and not decreased. + /// + [JsonProperty("size", NullValueHandling = NullValueHandling.Ignore)] + public SizeEnum? Size { get; set; } /// /// Name that identifies the environment. /// diff --git a/src/IBM.WatsonDeveloperCloud.LanguageTranslator.v2/IBM.WatsonDeveloperCloud.LanguageTranslator.v2.csproj b/src/IBM.WatsonDeveloperCloud.LanguageTranslator.v2/IBM.WatsonDeveloperCloud.LanguageTranslator.v2.csproj index 2c1adcf939..ffcb1a9a4f 100644 --- a/src/IBM.WatsonDeveloperCloud.LanguageTranslator.v2/IBM.WatsonDeveloperCloud.LanguageTranslator.v2.csproj +++ b/src/IBM.WatsonDeveloperCloud.LanguageTranslator.v2/IBM.WatsonDeveloperCloud.LanguageTranslator.v2.csproj @@ -15,16 +15,6 @@ 2.9.0 - - full - true - - - - full - true - - diff --git a/src/IBM.WatsonDeveloperCloud.LanguageTranslator.v2/LanguageTranslatorService.cs b/src/IBM.WatsonDeveloperCloud.LanguageTranslator.v2/LanguageTranslatorService.cs index e37da9e61d..db202e09ae 100644 --- a/src/IBM.WatsonDeveloperCloud.LanguageTranslator.v2/LanguageTranslatorService.cs +++ b/src/IBM.WatsonDeveloperCloud.LanguageTranslator.v2/LanguageTranslatorService.cs @@ -32,14 +32,13 @@ public partial class LanguageTranslatorService : WatsonService, ILanguageTransla { const string SERVICE_NAME = "language_translator"; const string URL = "https://gateway.watsonplatform.net/language-translator/api"; - [Obsolete("Language Translator v3 is now available. The v2 Language Translator API will no longer be available after July 31, 2018. To take advantage of the latest service enhancements, migrate to the v3 API. View the [Migrating to Language Translator v3](https://console.bluemix.net/docs/services/language-translator/migrating.html) page for more information.")] public LanguageTranslatorService() : base(SERVICE_NAME, URL) { if(!string.IsNullOrEmpty(this.Endpoint)) this.Endpoint = URL; - } - - [Obsolete("Language Translator v3 is now available. The v2 Language Translator API will no longer be available after July 31, 2018. To take advantage of the latest service enhancements, migrate to the v3 API. View the [Migrating to Language Translator v3](https://console.bluemix.net/docs/services/language-translator/migrating.html) page for more information.")] + } + + public LanguageTranslatorService(string userName, string password) : this() { if (string.IsNullOrEmpty(userName)) @@ -50,8 +49,8 @@ public LanguageTranslatorService(string userName, string password) : this() this.SetCredential(userName, password); } + - [Obsolete("Language Translator v3 is now available. The v2 Language Translator API will no longer be available after July 31, 2018. To take advantage of the latest service enhancements, migrate to the v3 API. View the [Migrating to Language Translator v3](https://console.bluemix.net/docs/services/language-translator/migrating.html) page for more information.")] public LanguageTranslatorService(TokenOptions options) : this() { if (string.IsNullOrEmpty(options.IamApiKey) && string.IsNullOrEmpty(options.IamAccessToken)) @@ -68,7 +67,6 @@ public LanguageTranslatorService(TokenOptions options) : this() _tokenManager = new TokenManager(options); } - [Obsolete("Language Translator v3 is now available. The v2 Language Translator API will no longer be available after July 31, 2018. To take advantage of the latest service enhancements, migrate to the v3 API. View the [Migrating to Language Translator v3](https://console.bluemix.net/docs/services/language-translator/migrating.html) page for more information.")] public LanguageTranslatorService(IClient httpClient) : this() { if (httpClient == null) @@ -94,14 +92,14 @@ public TranslationResult Translate(TranslateRequest request, Dictionary cust try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v2/identify"); @@ -177,14 +175,14 @@ public IdentifiableLanguages ListIdentifiableLanguages(Dictionary try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.DeleteAsync($"{this.Endpoint}/v2/models/{modelId}"); @@ -351,14 +349,14 @@ public TranslationModel GetModel(string modelId, Dictionary cust try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v2/models/{modelId}"); @@ -395,14 +393,14 @@ public TranslationModels ListModels(string source = null, string target = null, try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v2/models"); diff --git a/src/IBM.WatsonDeveloperCloud.LanguageTranslator.v3/IBM.WatsonDeveloperCloud.LanguageTranslator.v3.csproj b/src/IBM.WatsonDeveloperCloud.LanguageTranslator.v3/IBM.WatsonDeveloperCloud.LanguageTranslator.v3.csproj index 770def63a0..cc705fc435 100644 --- a/src/IBM.WatsonDeveloperCloud.LanguageTranslator.v3/IBM.WatsonDeveloperCloud.LanguageTranslator.v3.csproj +++ b/src/IBM.WatsonDeveloperCloud.LanguageTranslator.v3/IBM.WatsonDeveloperCloud.LanguageTranslator.v3.csproj @@ -15,16 +15,6 @@ 2.9.0 - - full - true - - - - full - true - - diff --git a/src/IBM.WatsonDeveloperCloud.LanguageTranslator.v3/LanguageTranslatorService.cs b/src/IBM.WatsonDeveloperCloud.LanguageTranslator.v3/LanguageTranslatorService.cs index 7d357e8b67..f6681a0ef5 100644 --- a/src/IBM.WatsonDeveloperCloud.LanguageTranslator.v3/LanguageTranslatorService.cs +++ b/src/IBM.WatsonDeveloperCloud.LanguageTranslator.v3/LanguageTranslatorService.cs @@ -45,6 +45,7 @@ public LanguageTranslatorService() : base(SERVICE_NAME, URL) this.Endpoint = URL; } + public LanguageTranslatorService(string userName, string password, string versionDate) : this() { if (string.IsNullOrEmpty(userName)) @@ -59,6 +60,7 @@ public LanguageTranslatorService(string userName, string password, string versio VersionDate = versionDate; } + public LanguageTranslatorService(TokenOptions options, string versionDate) : this() { @@ -110,14 +112,14 @@ public TranslationResult Translate(TranslateRequest request, Dictionary cust try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v3/identify"); @@ -203,14 +205,14 @@ public IdentifiableLanguages ListIdentifiableLanguages(Dictionary try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.DeleteAsync($"{this.Endpoint}/v3/models/{modelId}"); @@ -394,14 +396,14 @@ public TranslationModel GetModel(string modelId, Dictionary cust try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v3/models/{modelId}"); @@ -444,14 +446,14 @@ public TranslationModels ListModels(string source = null, string target = null, try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v3/models"); diff --git a/src/IBM.WatsonDeveloperCloud.NaturalLanguageClassifier.v1/IBM.WatsonDeveloperCloud.NaturalLanguageClassifier.v1.csproj b/src/IBM.WatsonDeveloperCloud.NaturalLanguageClassifier.v1/IBM.WatsonDeveloperCloud.NaturalLanguageClassifier.v1.csproj index f7db7df4d4..c0c934ffb1 100644 --- a/src/IBM.WatsonDeveloperCloud.NaturalLanguageClassifier.v1/IBM.WatsonDeveloperCloud.NaturalLanguageClassifier.v1.csproj +++ b/src/IBM.WatsonDeveloperCloud.NaturalLanguageClassifier.v1/IBM.WatsonDeveloperCloud.NaturalLanguageClassifier.v1.csproj @@ -15,16 +15,6 @@ 2.9.0 - - full - true - - - - full - true - - diff --git a/src/IBM.WatsonDeveloperCloud.NaturalLanguageClassifier.v1/NaturalLanguageClassifierService.cs b/src/IBM.WatsonDeveloperCloud.NaturalLanguageClassifier.v1/NaturalLanguageClassifierService.cs index f6d73e18d6..df46e778a7 100644 --- a/src/IBM.WatsonDeveloperCloud.NaturalLanguageClassifier.v1/NaturalLanguageClassifierService.cs +++ b/src/IBM.WatsonDeveloperCloud.NaturalLanguageClassifier.v1/NaturalLanguageClassifierService.cs @@ -39,6 +39,7 @@ public NaturalLanguageClassifierService() : base(SERVICE_NAME, URL) this.Endpoint = URL; } + public NaturalLanguageClassifierService(string userName, string password) : this() { if (string.IsNullOrEmpty(userName)) @@ -49,6 +50,7 @@ public NaturalLanguageClassifierService(string userName, string password) : this this.SetCredential(userName, password); } + public NaturalLanguageClassifierService(TokenOptions options) : this() { @@ -94,14 +96,14 @@ public Classification Classify(string classifierId, ClassifyInput body, Dictiona try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/classifiers/{classifierId}/classify"); @@ -143,14 +145,14 @@ public ClassificationCollection ClassifyCollection(string classifierId, Classify try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/classifiers/{classifierId}/classify_collection"); @@ -215,14 +217,14 @@ public Classifier CreateClassifier(System.IO.FileStream metadata, System.IO.File formData.Add(trainingDataContent, "training_data", trainingData.Name); } - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/classifiers"); @@ -256,14 +258,14 @@ public BaseModel DeleteClassifier(string classifierId, Dictionary try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/classifiers/{classifierId}"); @@ -337,14 +339,14 @@ public ClassifierList ListClassifiers(Dictionary customData = nu try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/classifiers"); diff --git a/src/IBM.WatsonDeveloperCloud.NaturalLanguageUnderstanding.v1/IBM.WatsonDeveloperCloud.NaturalLanguageUnderstanding.v1.csproj b/src/IBM.WatsonDeveloperCloud.NaturalLanguageUnderstanding.v1/IBM.WatsonDeveloperCloud.NaturalLanguageUnderstanding.v1.csproj index 17f56cc2ff..4d9b92083f 100644 --- a/src/IBM.WatsonDeveloperCloud.NaturalLanguageUnderstanding.v1/IBM.WatsonDeveloperCloud.NaturalLanguageUnderstanding.v1.csproj +++ b/src/IBM.WatsonDeveloperCloud.NaturalLanguageUnderstanding.v1/IBM.WatsonDeveloperCloud.NaturalLanguageUnderstanding.v1.csproj @@ -15,16 +15,6 @@ 2.9.0 - - full - true - - - - full - true - - diff --git a/src/IBM.WatsonDeveloperCloud.NaturalLanguageUnderstanding.v1/NaturalLanguageUnderstandingService.cs b/src/IBM.WatsonDeveloperCloud.NaturalLanguageUnderstanding.v1/NaturalLanguageUnderstandingService.cs index 412ec69d11..b4b3026ff0 100644 --- a/src/IBM.WatsonDeveloperCloud.NaturalLanguageUnderstanding.v1/NaturalLanguageUnderstandingService.cs +++ b/src/IBM.WatsonDeveloperCloud.NaturalLanguageUnderstanding.v1/NaturalLanguageUnderstandingService.cs @@ -42,6 +42,7 @@ public NaturalLanguageUnderstandingService() : base(SERVICE_NAME, URL) this.Endpoint = URL; } + public NaturalLanguageUnderstandingService(string userName, string password, string versionDate) : this() { if (string.IsNullOrEmpty(userName)) @@ -56,6 +57,7 @@ public NaturalLanguageUnderstandingService(string userName, string password, str VersionDate = versionDate; } + public NaturalLanguageUnderstandingService(TokenOptions options, string versionDate) : this() { @@ -145,14 +147,14 @@ public AnalysisResults Analyze(Parameters parameters, Dictionary try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/analyze"); @@ -192,14 +194,14 @@ public InlineResponse200 DeleteModel(string modelId, Dictionary try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.DeleteAsync($"{this.Endpoint}/v1/models/{modelId}"); @@ -237,14 +239,14 @@ public ListModelsResults ListModels(Dictionary customData = null try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/models"); diff --git a/src/IBM.WatsonDeveloperCloud.PersonalityInsights.v3/IBM.WatsonDeveloperCloud.PersonalityInsights.v3.csproj b/src/IBM.WatsonDeveloperCloud.PersonalityInsights.v3/IBM.WatsonDeveloperCloud.PersonalityInsights.v3.csproj index f924a3065a..0b8d3a94c6 100644 --- a/src/IBM.WatsonDeveloperCloud.PersonalityInsights.v3/IBM.WatsonDeveloperCloud.PersonalityInsights.v3.csproj +++ b/src/IBM.WatsonDeveloperCloud.PersonalityInsights.v3/IBM.WatsonDeveloperCloud.PersonalityInsights.v3.csproj @@ -15,16 +15,6 @@ 2.9.0 - - full - true - - - - full - true - - diff --git a/src/IBM.WatsonDeveloperCloud.PersonalityInsights.v3/PersonalityInsightsService.cs b/src/IBM.WatsonDeveloperCloud.PersonalityInsights.v3/PersonalityInsightsService.cs index c2097fb2fb..84555a3da7 100644 --- a/src/IBM.WatsonDeveloperCloud.PersonalityInsights.v3/PersonalityInsightsService.cs +++ b/src/IBM.WatsonDeveloperCloud.PersonalityInsights.v3/PersonalityInsightsService.cs @@ -42,6 +42,7 @@ public PersonalityInsightsService() : base(SERVICE_NAME, URL) this.Endpoint = URL; } + public PersonalityInsightsService(string userName, string password, string versionDate) : this() { if (string.IsNullOrEmpty(userName)) @@ -56,6 +57,7 @@ public PersonalityInsightsService(string userName, string password, string versi VersionDate = versionDate; } + public PersonalityInsightsService(TokenOptions options, string versionDate) : this() { @@ -103,10 +105,11 @@ public PersonalityInsightsService(IClient httpClient) : this() /// character set). When specifying a content type of plain text or HTML, include the `charset` parameter to /// indicate the character encoding of the input text; for example: `Content-Type: text/plain;charset=utf-8`. /// - /// For detailed information about calling the service and the responses it can generate, see [Requesting a - /// profile](https://console.bluemix.net/docs/services/personality-insights/input.html), [Understanding a JSON - /// profile](https://console.bluemix.net/docs/services/personality-insights/output.html), and [Understanding a - /// CSV profile](https://console.bluemix.net/docs/services/personality-insights/output-csv.html). + /// **See also:** + /// * [Requesting a profile](https://console.bluemix.net/docs/services/personality-insights/input.html) + /// * [Understanding a JSON profile](https://console.bluemix.net/docs/services/personality-insights/output.html) + /// * [Understanding a CSV + /// profile](https://console.bluemix.net/docs/services/personality-insights/output-csv.html). /// /// A maximum of 20 MB of content to analyze, though the service requires much less text; /// for more information, see [Providing sufficient @@ -152,14 +155,14 @@ public Profile Profile(Content content, string contentType, string contentLangua try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v3/profile"); @@ -209,10 +212,11 @@ public Profile Profile(Content content, string contentType, string contentLangua /// character set). When specifying a content type of plain text or HTML, include the `charset` parameter to /// indicate the character encoding of the input text; for example: `Content-Type: text/plain;charset=utf-8`. /// - /// For detailed information about calling the service and the responses it can generate, see [Requesting a - /// profile](https://console.bluemix.net/docs/services/personality-insights/input.html), [Understanding a JSON - /// profile](https://console.bluemix.net/docs/services/personality-insights/output.html), and [Understanding a - /// CSV profile](https://console.bluemix.net/docs/services/personality-insights/output-csv.html). + /// **See also:** + /// * [Requesting a profile](https://console.bluemix.net/docs/services/personality-insights/input.html) + /// * [Understanding a JSON profile](https://console.bluemix.net/docs/services/personality-insights/output.html) + /// * [Understanding a CSV + /// profile](https://console.bluemix.net/docs/services/personality-insights/output-csv.html). /// /// A maximum of 20 MB of content to analyze, though the service requires much less text; /// for more information, see [Providing sufficient @@ -258,14 +262,14 @@ public System.IO.MemoryStream ProfileAsCsv(Content content, string contentType, try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v3/profile"); diff --git a/src/IBM.WatsonDeveloperCloud.SpeechToText.v1/IBM.WatsonDeveloperCloud.SpeechToText.v1.csproj b/src/IBM.WatsonDeveloperCloud.SpeechToText.v1/IBM.WatsonDeveloperCloud.SpeechToText.v1.csproj index 926cac13c8..65fbab581f 100644 --- a/src/IBM.WatsonDeveloperCloud.SpeechToText.v1/IBM.WatsonDeveloperCloud.SpeechToText.v1.csproj +++ b/src/IBM.WatsonDeveloperCloud.SpeechToText.v1/IBM.WatsonDeveloperCloud.SpeechToText.v1.csproj @@ -15,16 +15,6 @@ 2.9.0 - - full - true - - - - full - true - - diff --git a/src/IBM.WatsonDeveloperCloud.SpeechToText.v1/ISpeechToTextService.cs b/src/IBM.WatsonDeveloperCloud.SpeechToText.v1/ISpeechToTextService.cs index 3b9dba095d..81deedea7d 100644 --- a/src/IBM.WatsonDeveloperCloud.SpeechToText.v1/ISpeechToTextService.cs +++ b/src/IBM.WatsonDeveloperCloud.SpeechToText.v1/ISpeechToTextService.cs @@ -25,7 +25,7 @@ public partial interface ISpeechToTextService { SpeechModel GetModel(string modelId, Dictionary customData = null); SpeechModels ListModels(Dictionary customData = null); - SpeechRecognitionResults RecognizeSessionless(byte[] audio, string contentType, string model = null, string customizationId = 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, Dictionary customData = null); + SpeechRecognitionResults Recognize(byte[] audio, string contentType, string model = null, string customizationId = 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, Dictionary customData = null); RecognitionJob CheckJob(string id, Dictionary customData = null); RecognitionJobs CheckJobs(Dictionary customData = null); RecognitionJob CreateJob(byte[] audio, string contentType, string model = null, string callbackUrl = null, string events = null, string userToken = null, long? resultsTtl = null, string customizationId = 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, Dictionary customData = null); diff --git a/src/IBM.WatsonDeveloperCloud.SpeechToText.v1/Model/SpeechRecognitionAlternative.cs b/src/IBM.WatsonDeveloperCloud.SpeechToText.v1/Model/SpeechRecognitionAlternative.cs index d7683be59f..b13fdbd4eb 100644 --- a/src/IBM.WatsonDeveloperCloud.SpeechToText.v1/Model/SpeechRecognitionAlternative.cs +++ b/src/IBM.WatsonDeveloperCloud.SpeechToText.v1/Model/SpeechRecognitionAlternative.cs @@ -42,7 +42,7 @@ public class SpeechRecognitionAlternative : BaseModel /// `[[\"hello\",0.0,1.2],[\"world\",1.2,2.5]]`. 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: @@ -50,7 +50,7 @@ public class SpeechRecognitionAlternative : BaseModel /// as final. /// [JsonProperty("word_confidence", NullValueHandling = NullValueHandling.Ignore)] - public string[][] WordConfidence { get; set; } + public List WordConfidence { get; set; } } } diff --git a/src/IBM.WatsonDeveloperCloud.SpeechToText.v1/SpeechToTextService.cs b/src/IBM.WatsonDeveloperCloud.SpeechToText.v1/SpeechToTextService.cs index 17b93bfa7f..4e74425e65 100644 --- a/src/IBM.WatsonDeveloperCloud.SpeechToText.v1/SpeechToTextService.cs +++ b/src/IBM.WatsonDeveloperCloud.SpeechToText.v1/SpeechToTextService.cs @@ -41,6 +41,7 @@ public SpeechToTextService() : base(SERVICE_NAME, URL) this.Endpoint = URL; } + public SpeechToTextService(string userName, string password) : this() { if (string.IsNullOrEmpty(userName)) @@ -51,6 +52,7 @@ public SpeechToTextService(string userName, string password) : this() this.SetCredential(userName, password); } + public SpeechToTextService(TokenOptions options) : this() { @@ -81,6 +83,9 @@ public SpeechToTextService(IClient httpClient) : this() /// /// Gets information for a single specified language model that is available for use with the service. The /// information includes the name of the model and its minimum sampling rate in Hertz, among other things. + /// + /// **See also:** [Languages and + /// models](https://console.bluemix.net/docs/services/speech-to-text/input.html#models). /// /// The identifier of the model in the form of its name from the output of the **Get /// models** method. @@ -94,14 +99,14 @@ public SpeechModel GetModel(string modelId, Dictionary customDat try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/models/{modelId}"); @@ -125,6 +130,9 @@ public SpeechModel GetModel(string modelId, Dictionary customDat /// /// Lists all language models that are available for use with the service. The information includes the name of /// the model and its minimum sampling rate in Hertz, among other things. + /// + /// **See also:** [Languages and + /// models](https://console.bluemix.net/docs/services/speech-to-text/input.html#models). /// /// Custom data object to pass data including custom request headers. /// SpeechModels @@ -134,14 +142,14 @@ public SpeechModels ListModels(Dictionary customData = null) try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/models"); @@ -168,6 +176,9 @@ public SpeechModels ListModels(Dictionary customData = null) /// downmixes the audio to one-channel mono during transcoding. (For the `audio/l16` format, you can specify the /// endianness.) /// + /// **See also:** [Making a basic HTTP + /// request](https://console.bluemix.net/docs/services/speech-to-text/http.html#HTTP-basic). + /// /// ### Streaming mode /// /// For requests to transcribe live audio as it becomes available, you must set the `Transfer-Encoding` header @@ -177,10 +188,14 @@ public SpeechModels ListModels(Dictionary customData = null) /// seconds of audio (not processing time); use the `inactivity_timeout` parameter to change the default of 30 /// seconds. /// + /// **See also:** + /// * [Audio transmission](https://console.bluemix.net/docs/services/speech-to-text/input.html#transmission) + /// * [Timeouts](https://console.bluemix.net/docs/services/speech-to-text/input.html#timeouts) + /// /// ### Audio formats (content types) /// /// Use the `Content-Type` header to specify the audio format (MIME type) of the audio. The service accepts the - /// following formats: + /// following formats, including specifying the sampling rate, channels, and endianness where indicated. /// * `audio/basic` (Use only with narrowband models.) /// * `audio/flac` /// * `audio/l16` (Specify the sampling rate (`rate`) and optionally the number of channels (`channels`) and @@ -196,9 +211,7 @@ public SpeechModels ListModels(Dictionary customData = null) /// * `audio/webm;codecs=opus` /// * `audio/webm;codecs=vorbis` /// - /// For information about the supported audio formats, including specifying the sampling rate, channels, and - /// endianness for the indicated formats, see [Audio - /// formats](https://console.bluemix.net/docs/services/speech-to-text/audio-formats.html). + /// **See also:** [Audio formats](https://console.bluemix.net/docs/services/speech-to-text/audio-formats.html). /// /// ### Multipart speech recognition /// @@ -210,7 +223,7 @@ public SpeechModels ListModels(Dictionary customData = null) /// parameters used with the request are greater than the 8 KB limit imposed by most HTTP servers and proxies. /// You can encounter this limit, for example, if you want to spot a very large number of keywords. /// - /// For information about submitting a multipart request, see [Making a multipart HTTP + /// **See also:** [Making a multipart HTTP /// request](https://console.bluemix.net/docs/services/speech-to-text/http.html#HTTP-multi). /// /// The audio to transcribe in the format specified by the `Content-Type` header. @@ -286,7 +299,7 @@ public SpeechModels ListModels(Dictionary customData = null) /// default to false) /// Custom data object to pass data including custom request headers. /// SpeechRecognitionResults - public SpeechRecognitionResults RecognizeSessionless(byte[] audio, string contentType, string model = null, string customizationId = 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, Dictionary customData = null) + public SpeechRecognitionResults Recognize(byte[] audio, string contentType, string model = null, string customizationId = 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, Dictionary customData = null) { if (audio == null) throw new ArgumentNullException(nameof(audio)); @@ -296,14 +309,14 @@ public SpeechRecognitionResults RecognizeSessionless(byte[] audio, string conten try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/recognize"); @@ -321,8 +334,7 @@ public SpeechRecognitionResults RecognizeSessionless(byte[] audio, string conten restRequest.WithArgument("customization_weight", customizationWeight); if (inactivityTimeout != null) restRequest.WithArgument("inactivity_timeout", inactivityTimeout); - if (keywords != null) - restRequest.WithArgument("keywords", keywords != null && keywords.Count > 0 ? string.Join(",", keywords.ToArray()) : null); + restRequest.WithArgument("keywords", keywords != null && keywords.Count > 0 ? string.Join(",", keywords.ToArray()) : null); if (keywordsThreshold != null) restRequest.WithArgument("keywords_threshold", keywordsThreshold); if (maxAlternatives != null) @@ -338,12 +350,8 @@ public SpeechRecognitionResults RecognizeSessionless(byte[] audio, string conten if (smartFormatting != null) restRequest.WithArgument("smart_formatting", smartFormatting); if (speakerLabels != null) - restRequest.WithArgument("speaker_labels", speakerLabels); - var audioContent = new ByteArrayContent(audio); - System.Net.Http.Headers.MediaTypeHeaderValue audioType; - System.Net.Http.Headers.MediaTypeHeaderValue.TryParse(contentType, out audioType); - audioContent.Headers.ContentType = audioType; - restRequest.WithBodyContent(audioContent); + restRequest.WithArgument("speaker_labels", speakerLabels); + restRequest.WithBody(audio); if (customData != null) restRequest.WithCustomData(customData); result = restRequest.As().Result; @@ -370,6 +378,9 @@ public SpeechRecognitionResults RecognizeSessionless(byte[] audio, string conten /// callback URL and the `recognitions.completed_with_results` event, and you can retrieve the results multiple /// times for as long as they remain available. Use the **Check jobs** method to request information about the /// most recent jobs associated with the calling user. + /// + /// **See also:** [Checking the status and retrieving the results of a + /// job](https://console.bluemix.net/docs/services/speech-to-text/async.html#job). /// /// The ID of the asynchronous job. /// Custom data object to pass data including custom request headers. @@ -382,14 +393,14 @@ public RecognitionJob CheckJob(string id, Dictionary customData try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/recognitions/{id}"); @@ -417,6 +428,9 @@ public RecognitionJob CheckJob(string id, Dictionary customData /// whose status is `completed` or not one of the latest 100 outstanding jobs, use the **Check a job** method. A /// job and its results remain available until you delete them with the **Delete a job** method or until the /// job's time to live expires, whichever comes first. + /// + /// **See also:** [Checking the status of the latest + /// jobs](https://console.bluemix.net/docs/services/speech-to-text/async.html#jobs). /// /// Custom data object to pass data including custom request headers. /// RecognitionJobs @@ -426,14 +440,14 @@ public RecognitionJobs CheckJobs(Dictionary customData = null) try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/recognitions"); @@ -469,10 +483,9 @@ public RecognitionJobs CheckJobs(Dictionary customData = null) /// The two approaches are not mutually exclusive. You can poll the service for job status or obtain results /// from the service manually even if you include a callback URL. In both cases, you can include the /// `results_ttl` parameter to specify how long the results are to remain available after the job is complete. - /// For detailed usage information about the two approaches, including callback notifications, see [Creating a - /// job](https://console.bluemix.net/docs/services/speech-to-text/async.html#create). Using the HTTPS **Check a - /// job** method to retrieve results is more secure than receiving them via callback notification over HTTP - /// because it provides confidentiality in addition to authentication and data integrity. + /// Using the HTTPS **Check a job** method to retrieve results is more secure than receiving them via callback + /// notification over HTTP because it provides confidentiality in addition to authentication and data integrity. + /// /// /// The method supports the same basic parameters as other HTTP and WebSocket recognition requests. It also /// supports the following parameters specific to the asynchronous interface: @@ -483,11 +496,14 @@ public RecognitionJobs CheckJobs(Dictionary customData = null) /// /// The service imposes a data size limit of 100 MB. It automatically detects the endianness of the incoming /// audio and, for audio that includes multiple channels, downmixes the audio to one-channel mono during - /// transcoding. (For the `audio/l16` format, you can specify the endianness.) + /// transcoding. + /// + /// **See also:** [Creating a job](https://console.bluemix.net/docs/services/speech-to-text/async.html#create). /// /// ### Audio formats (content types) /// - /// Use the `Content-Type` parameter to specify the audio format (MIME type) of the audio: + /// Use the `Content-Type` header to specify the audio format (MIME type) of the audio. The service accepts the + /// following formats, including specifying the sampling rate, channels, and endianness where indicated. /// * `audio/basic` (Use only with narrowband models.) /// * `audio/flac` /// * `audio/l16` (Specify the sampling rate (`rate`) and optionally the number of channels (`channels`) and @@ -503,9 +519,7 @@ public RecognitionJobs CheckJobs(Dictionary customData = null) /// * `audio/webm;codecs=opus` /// * `audio/webm;codecs=vorbis` /// - /// For information about the supported audio formats, including specifying the sampling rate, channels, and - /// endianness for the indicated formats, see [Audio - /// formats](https://console.bluemix.net/docs/services/speech-to-text/audio-formats.html). + /// **See also:** [Audio formats](https://console.bluemix.net/docs/services/speech-to-text/audio-formats.html). /// /// The audio to transcribe in the format specified by the `Content-Type` header. /// The type of the input. @@ -621,14 +635,14 @@ public RecognitionJob CreateJob(byte[] audio, string contentType, string model = try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/recognitions"); @@ -654,8 +668,7 @@ public RecognitionJob CreateJob(byte[] audio, string contentType, string model = restRequest.WithArgument("customization_weight", customizationWeight); if (inactivityTimeout != null) restRequest.WithArgument("inactivity_timeout", inactivityTimeout); - if (keywords != null) - restRequest.WithArgument("keywords", keywords != null && keywords.Count > 0 ? string.Join(",", keywords.ToArray()) : null); + restRequest.WithArgument("keywords", keywords != null && keywords.Count > 0 ? string.Join(",", keywords.ToArray()) : null); if (keywordsThreshold != null) restRequest.WithArgument("keywords_threshold", keywordsThreshold); if (maxAlternatives != null) @@ -671,12 +684,8 @@ public RecognitionJob CreateJob(byte[] audio, string contentType, string model = if (smartFormatting != null) restRequest.WithArgument("smart_formatting", smartFormatting); if (speakerLabels != null) - restRequest.WithArgument("speaker_labels", speakerLabels); - var audioContent = new ByteArrayContent(audio); - System.Net.Http.Headers.MediaTypeHeaderValue audioType; - System.Net.Http.Headers.MediaTypeHeaderValue.TryParse(contentType, out audioType); - audioContent.Headers.ContentType = audioType; - restRequest.WithBodyContent(audioContent); + restRequest.WithArgument("speaker_labels", speakerLabels); + restRequest.WithBody(audio); if (customData != null) restRequest.WithCustomData(customData); result = restRequest.As().Result; @@ -699,6 +708,8 @@ public RecognitionJob CreateJob(byte[] audio, string contentType, string model = /// a job, its results are no longer available. The service automatically deletes a job and its results when the /// time to live for the results expires. You must submit the request with the service credentials of the user /// who created the job. + /// + /// **See also:** [Deleting a job](https://console.bluemix.net/docs/services/speech-to-text/async.html#delete). /// /// The ID of the asynchronous job. /// Custom data object to pass data including custom request headers. @@ -711,14 +722,14 @@ public BaseModel DeleteJob(string id, Dictionary customData = nu try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.DeleteAsync($"{this.Endpoint}/v1/recognitions/{id}"); @@ -764,8 +775,9 @@ public BaseModel DeleteJob(string id, Dictionary customData = nu /// provides authentication and data integrity for HTTP communications. /// /// After you successfully register a callback URL, you can use it with an indefinite number of recognition - /// requests. You can register a maximum of 20 callback URLS in a one-hour span of time. For more information, - /// see [Registering a callback + /// requests. You can register a maximum of 20 callback URLS in a one-hour span of time. + /// + /// **See also:** [Registering a callback /// URL](https://console.bluemix.net/docs/services/speech-to-text/async.html#register). /// /// An HTTP or HTTPS URL to which callback notifications are to be sent. To be @@ -786,14 +798,14 @@ public RegisterStatus RegisterCallback(string callbackUrl, string userSecret = n try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/register_callback"); @@ -822,6 +834,9 @@ public RegisterStatus RegisterCallback(string callbackUrl, string userSecret = n /// Unregisters a callback URL that was previously white-listed with a **Register a callback** request for use /// with the asynchronous interface. Once unregistered, the URL can no longer be used with asynchronous /// recognition requests. + /// + /// **See also:** [Unregistering a callback + /// URL](https://console.bluemix.net/docs/services/speech-to-text/async.html#unregister). /// /// The callback URL that is to be unregistered. /// Custom data object to pass data including custom request headers. @@ -834,14 +849,14 @@ public BaseModel UnregisterCallback(string callbackUrl, Dictionary /// A `CreateLanguageModel` object that provides basic information about the /// new custom language model. @@ -880,14 +898,14 @@ public LanguageModel CreateLanguageModel(CreateLanguageModel createLanguageModel try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/customizations"); @@ -913,6 +931,9 @@ public LanguageModel CreateLanguageModel(CreateLanguageModel createLanguageModel /// Deletes an existing custom language model. The custom model cannot be deleted if another request, such as /// adding a corpus to the model, is currently being processed. You must use credentials for the instance of the /// service that owns a model to delete it. + /// + /// **See also:** [Deleting a custom language + /// model](https://console.bluemix.net/docs/services/speech-to-text/language-models.html#deleteModel). /// /// The customization ID (GUID) of the custom language model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -926,14 +947,14 @@ public BaseModel DeleteLanguageModel(string customizationId, Dictionary /// The customization ID (GUID) of the custom language model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -970,14 +994,14 @@ public LanguageModel GetLanguageModel(string customizationId, Dictionary /// The identifier of the language for which custom language or custom acoustic models /// are to be returned (for example, `en-US`). Omit the parameter to see all custom language or custom acoustic @@ -1015,14 +1042,14 @@ public LanguageModels ListLanguageModels(string language = null, Dictionary /// The customization ID (GUID) of the custom language model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -1063,14 +1093,14 @@ public BaseModel ResetLanguageModel(string customizationId, Dictionary /// The customization ID (GUID) of the custom language model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -1146,14 +1179,14 @@ public BaseModel TrainLanguageModel(string customizationId, string wordTypeToAdd try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/customizations/{customizationId}/train"); @@ -1192,8 +1225,8 @@ public BaseModel TrainLanguageModel(string customizationId, string wordTypeToAdd /// `upgrading`. When the upgrade is complete, the model resumes the status that it had prior to upgrade. The /// service cannot accept subsequent requests for the model until the upgrade completes. /// - /// For more information, see [Upgrading custom - /// models](https://console.bluemix.net/docs/services/speech-to-text/custom-upgrade.html). + /// **See also:** [Upgrading a custom language + /// model](https://console.bluemix.net/docs/services/speech-to-text/custom-upgrade.html#upgradeLanguage). /// /// The customization ID (GUID) of the custom language model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -1207,14 +1240,14 @@ public BaseModel UpgradeLanguageModel(string customizationId, Dictionary /// The customization ID (GUID) of the custom language model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -1309,14 +1346,14 @@ public BaseModel AddCorpus(string customizationId, string corpusName, System.IO. formData.Add(corpusFileContent, "corpus_file", corpusFile.Name); } - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/customizations/{customizationId}/corpora/{corpusName}"); @@ -1347,6 +1384,9 @@ public BaseModel AddCorpus(string customizationId, string corpusName, System.IO. /// method. Removing a corpus does not affect the custom model until you train the model with the **Train a /// custom language model** method. You must use credentials for the instance of the service that owns a model /// to delete its corpora. + /// + /// **See also:** [Deleting a corpus from a custom language + /// model](https://console.bluemix.net/docs/services/speech-to-text/language-corpora.html#deleteCorpus). /// /// The customization ID (GUID) of the custom language model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -1363,14 +1403,14 @@ public BaseModel DeleteCorpus(string customizationId, string corpusName, Diction try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.DeleteAsync($"{this.Endpoint}/v1/customizations/{customizationId}/corpora/{corpusName}"); @@ -1395,6 +1435,9 @@ public BaseModel DeleteCorpus(string customizationId, string corpusName, Diction /// Gets information about a corpus from a custom language model. The information includes the total number of /// words and out-of-vocabulary (OOV) words, name, and status of the corpus. You must use credentials for the /// instance of the service that owns a model to list its corpora. + /// + /// **See also:** [Listing corpora for a custom language + /// model](https://console.bluemix.net/docs/services/speech-to-text/language-corpora.html#listCorpora). /// /// The customization ID (GUID) of the custom language model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -1411,14 +1454,14 @@ public Corpus GetCorpus(string customizationId, string corpusName, Dictionary /// The customization ID (GUID) of the custom language model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -1456,14 +1502,14 @@ public Corpora ListCorpora(string customizationId, Dictionary cu try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/customizations/{customizationId}/corpora"); @@ -1500,19 +1546,22 @@ public Corpora ListCorpora(string customizationId, Dictionary cu /// * The `sounds_like` field provides an array of one or more pronunciations for the word. Use the parameter to /// specify how the word can be pronounced by users. Use the parameter for words that are difficult to /// pronounce, foreign words, acronyms, and so on. For example, you might specify that the word `IEEE` can sound - /// like `i triple e`. You can specify a maximum of five sounds-like pronunciations for a word. For information - /// about pronunciation rules, see [Using the sounds_like - /// field](https://console.bluemix.net/docs/services/speech-to-text/language-resource.html#soundsLike). + /// like `i triple e`. You can specify a maximum of five sounds-like pronunciations for a word. /// * The `display_as` field provides a different way of spelling the word in a transcript. Use the parameter /// when you want the word to appear different from its usual representation or from its spelling in corpora /// training data. For example, you might indicate that the word `IBM(trademark)` is to be displayed as - /// `IBM™`. For more information, see [Using the display_as - /// field](https://console.bluemix.net/docs/services/speech-to-text/language-resource.html#displayAs). + /// `IBM™`. /// /// /// If you add a custom word that already exists in the words resource for the custom model, the new definition /// overwrites the existing data for the word. If the service encounters an error, it does not add the word to /// the words resource. Use the **List a custom word** method to review the word that you add. + /// + /// **See also:** + /// * [Working with custom + /// words](https://console.bluemix.net/docs/services/speech-to-text/language-resource.html#workingWords) + /// * [Add words to the custom language + /// model](https://console.bluemix.net/docs/services/speech-to-text/language-create.html#addWords). /// /// The customization ID (GUID) of the custom language model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -1535,14 +1584,14 @@ public BaseModel AddWord(string customizationId, string wordName, CustomWord cus try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PutAsync($"{this.Endpoint}/v1/customizations/{customizationId}/words/{wordName}"); @@ -1581,14 +1630,11 @@ public BaseModel AddWord(string customizationId, string wordName, CustomWord cus /// * The `sounds_like` field provides an array of one or more pronunciations for the word. Use the parameter to /// specify how the word can be pronounced by users. Use the parameter for words that are difficult to /// pronounce, foreign words, acronyms, and so on. For example, you might specify that the word `IEEE` can sound - /// like `i triple e`. You can specify a maximum of five sounds-like pronunciations for a word. For information - /// about pronunciation rules, see [Using the sounds_like - /// field](https://console.bluemix.net/docs/services/speech-to-text/language-resource.html#soundsLike). + /// like `i triple e`. You can specify a maximum of five sounds-like pronunciations for a word. /// * The `display_as` field provides a different way of spelling the word in a transcript. Use the parameter /// when you want the word to appear different from its usual representation or from its spelling in corpora /// training data. For example, you might indicate that the word `IBM(trademark)` is to be displayed as - /// `IBM™`. For more information, see [Using the display_as - /// field](https://console.bluemix.net/docs/services/speech-to-text/language-resource.html#displayAs). + /// `IBM™`. /// /// /// If you add a custom word that already exists in the words resource for the custom model, the new definition @@ -1609,6 +1655,12 @@ public BaseModel AddWord(string customizationId, string wordName, CustomWord cus /// Words with an invalid `sounds_like` field include an `error` field that describes the problem. You can use /// other words-related methods to correct errors, eliminate typos, and modify how words are pronounced as /// needed. + /// + /// **See also:** + /// * [Working with custom + /// words](https://console.bluemix.net/docs/services/speech-to-text/language-resource.html#workingWords) + /// * [Add words to the custom language + /// model](https://console.bluemix.net/docs/services/speech-to-text/language-create.html#addWords). /// /// The customization ID (GUID) of the custom language model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -1626,14 +1678,14 @@ public BaseModel AddWords(string customizationId, CustomWords customWords, Dicti try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/customizations/{customizationId}/words"); @@ -1662,6 +1714,9 @@ public BaseModel AddWords(string customizationId, CustomWords customWords, Dicti /// Removing a custom word does not affect the custom model until you train the model with the **Train a custom /// language model** method. You must use credentials for the instance of the service that owns a model to /// delete its words. + /// + /// **See also:** [Deleting a word from a custom language + /// model](https://console.bluemix.net/docs/services/speech-to-text/language-words.html#deleteWord). /// /// The customization ID (GUID) of the custom language model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -1680,14 +1735,14 @@ public BaseModel DeleteWord(string customizationId, string wordName, Dictionary< try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.DeleteAsync($"{this.Endpoint}/v1/customizations/{customizationId}/words/{wordName}"); @@ -1711,6 +1766,9 @@ public BaseModel DeleteWord(string customizationId, string wordName, Dictionary< /// /// Gets information about a custom word from a custom language model. You must use credentials for the instance /// of the service that owns a model to query information about its words. + /// + /// **See also:** [Listing words from a custom language + /// model](https://console.bluemix.net/docs/services/speech-to-text/language-words.html#listWords). /// /// The customization ID (GUID) of the custom language model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -1729,14 +1787,14 @@ public Word GetWord(string customizationId, string wordName, Dictionary /// The customization ID (GUID) of the custom language model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -1786,14 +1847,14 @@ public Words ListWords(string customizationId, string wordType = null, string so try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/customizations/{customizationId}/words"); @@ -1821,6 +1882,9 @@ public Words ListWords(string customizationId, string wordType = null, string so /// Creates a new custom acoustic model for a specified base model. The custom acoustic model can be used only /// with the base model for which it is created. The model is owned by the instance of the service whose /// credentials are used to create it. + /// + /// **See also:** [Create a custom acoustic + /// model](https://console.bluemix.net/docs/services/speech-to-text/acoustic-create.html#createModel). /// /// A `CreateAcousticModel` object that provides basic information about the /// new custom acoustic model. @@ -1834,14 +1898,14 @@ public AcousticModel CreateAcousticModel(CreateAcousticModel createAcousticModel try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/acoustic_customizations"); @@ -1867,6 +1931,9 @@ public AcousticModel CreateAcousticModel(CreateAcousticModel createAcousticModel /// Deletes an existing custom acoustic model. The custom model cannot be deleted if another request, such as /// adding an audio resource to the model, is currently being processed. You must use credentials for the /// instance of the service that owns a model to delete it. + /// + /// **See also:** [Deleting a custom acoustic + /// model](https://console.bluemix.net/docs/services/speech-to-text/acoustic-models.html#deleteModel). /// /// The customization ID (GUID) of the custom acoustic model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -1880,14 +1947,14 @@ public BaseModel DeleteAcousticModel(string customizationId, Dictionary /// The customization ID (GUID) of the custom acoustic model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -1924,14 +1994,14 @@ public AcousticModel GetAcousticModel(string customizationId, Dictionary /// The identifier of the language for which custom language or custom acoustic models /// are to be returned (for example, `en-US`). Omit the parameter to see all custom language or custom acoustic @@ -1969,14 +2042,14 @@ public AcousticModels ListAcousticModels(string language = null, Dictionary /// The customization ID (GUID) of the custom acoustic model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -2017,14 +2093,14 @@ public BaseModel ResetAcousticModel(string customizationId, Dictionary /// The customization ID (GUID) of the custom acoustic model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -2093,14 +2171,14 @@ public BaseModel TrainAcousticModel(string customizationId, string customLanguag try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/acoustic_customizations/{customizationId}/train"); @@ -2143,8 +2221,8 @@ public BaseModel TrainAcousticModel(string customizationId, string customLanguag /// model must be upgraded before the custom acoustic model can be upgraded. Omit the parameter if the custom /// acoustic model was not trained with a custom language model. /// - /// For more information, see [Upgrading custom - /// models](https://console.bluemix.net/docs/services/speech-to-text/custom-upgrade.html). + /// **See also:** [Upgrading a custom acoustic + /// model](https://console.bluemix.net/docs/services/speech-to-text/custom-upgrade.html#upgradeAcoustic). /// /// The customization ID (GUID) of the custom acoustic model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -2161,14 +2239,14 @@ public BaseModel UpgradeAcousticModel(string customizationId, string customLangu try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/acoustic_customizations/{customizationId}/upgrade_model"); @@ -2220,11 +2298,14 @@ public BaseModel UpgradeAcousticModel(string customizationId, string customLangu /// the audio resource, and it returns the status of the resource. Use a loop to check the status of the audio /// every few seconds until it becomes `ok`. /// + /// **See also:** [Add audio to the custom acoustic + /// model](https://console.bluemix.net/docs/services/speech-to-text/acoustic-create.html#addAudio). + /// /// ### Content types for audio-type resources /// /// You can add an individual audio file in any format that the service supports for speech recognition. For an /// audio-type resource, use the `Content-Type` parameter to specify the audio format (MIME type) of the audio - /// file: + /// file, including specifying the sampling rate, channels, and endianness where indicated. /// * `audio/basic` (Use only with narrowband models.) /// * `audio/flac` /// * `audio/l16` (Specify the sampling rate (`rate`) and optionally the number of channels (`channels`) and @@ -2240,9 +2321,7 @@ public BaseModel UpgradeAcousticModel(string customizationId, string customLangu /// * `audio/webm;codecs=opus` /// * `audio/webm;codecs=vorbis` /// - /// For information about the supported audio formats, including specifying the sampling rate, channels, and - /// endianness for the indicated formats, see [Audio - /// formats](https://console.bluemix.net/docs/services/speech-to-text/audio-formats.html). + /// **See also:** [Audio formats](https://console.bluemix.net/docs/services/speech-to-text/audio-formats.html). /// /// **Note:** The sampling rate of an audio file must match the sampling rate of the base model for the custom /// model: for broadband models, at least 16 kHz; for narrowband models, at least 8 kHz. If the sampling rate of @@ -2308,14 +2387,14 @@ public BaseModel AddAudio(string customizationId, string audioName, byte[] audio try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/acoustic_customizations/{customizationId}/audio/{audioName}"); @@ -2324,12 +2403,8 @@ public BaseModel AddAudio(string customizationId, string audioName, byte[] audio if (!string.IsNullOrEmpty(containedContentType)) restRequest.WithHeader("Contained-Content-Type", containedContentType); if (allowOverwrite != null) - restRequest.WithArgument("allow_overwrite", allowOverwrite); - var audioResourceContent = new ByteArrayContent(audioResource); - System.Net.Http.Headers.MediaTypeHeaderValue audioResourceType; - System.Net.Http.Headers.MediaTypeHeaderValue.TryParse(contentType, out audioResourceType); - audioResourceContent.Headers.ContentType = audioResourceType; - restRequest.WithBodyContent(audioResourceContent); + restRequest.WithArgument("allow_overwrite", allowOverwrite); + restRequest.WithBody(audioResource); if (customData != null) restRequest.WithCustomData(customData); result = restRequest.As().Result; @@ -2353,6 +2428,9 @@ public BaseModel AddAudio(string customizationId, string audioName, byte[] audio /// an archive resource. Removing an audio resource does not affect the custom model until you train the model /// on its updated data by using the **Train a custom acoustic model** method. You must use credentials for the /// instance of the service that owns a model to delete its audio resources. + /// + /// **See also:** [Deleting an audio resource from a custom acoustic + /// model](https://console.bluemix.net/docs/services/speech-to-text/acoustic-audio.html#deleteAudio). /// /// The customization ID (GUID) of the custom acoustic model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -2369,14 +2447,14 @@ public BaseModel DeleteAudio(string customizationId, string audioName, Dictionar try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.DeleteAsync($"{this.Endpoint}/v1/acoustic_customizations/{customizationId}/audio/{audioName}"); @@ -2414,6 +2492,9 @@ public BaseModel DeleteAudio(string customizationId, string audioName, Dictionar /// in the `container` field. /// /// You must use credentials for the instance of the service that owns a model to list its audio resources. + /// + /// **See also:** [Listing audio resources for a custom acoustic + /// model](https://console.bluemix.net/docs/services/speech-to-text/acoustic-audio.html#listAudio). /// /// The customization ID (GUID) of the custom acoustic model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -2430,14 +2511,14 @@ public AudioListing GetAudio(string customizationId, string audioName, Dictionar try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/acoustic_customizations/{customizationId}/audio/{audioName}"); @@ -2464,6 +2545,9 @@ public AudioListing GetAudio(string customizationId, string audioName, Dictionar /// the audio resource, which is important for checking the service's analysis of the resource in response to a /// request to add it to the custom acoustic model. You must use credentials for the instance of the service /// that owns a model to list its audio resources. + /// + /// **See also:** [Listing audio resources for a custom acoustic + /// model](https://console.bluemix.net/docs/services/speech-to-text/acoustic-audio.html#listAudio). /// /// The customization ID (GUID) of the custom acoustic model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -2477,14 +2561,14 @@ public AudioResources ListAudio(string customizationId, Dictionary /// The customer ID for which all data is to be deleted. @@ -2525,14 +2611,14 @@ public BaseModel DeleteUserData(string customerId, Dictionary cu try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.DeleteAsync($"{this.Endpoint}/v1/user_data"); diff --git a/src/IBM.WatsonDeveloperCloud.TextToSpeech.v1/IBM.WatsonDeveloperCloud.TextToSpeech.v1.csproj b/src/IBM.WatsonDeveloperCloud.TextToSpeech.v1/IBM.WatsonDeveloperCloud.TextToSpeech.v1.csproj index 145d2e66a9..589b3fcf4d 100644 --- a/src/IBM.WatsonDeveloperCloud.TextToSpeech.v1/IBM.WatsonDeveloperCloud.TextToSpeech.v1.csproj +++ b/src/IBM.WatsonDeveloperCloud.TextToSpeech.v1/IBM.WatsonDeveloperCloud.TextToSpeech.v1.csproj @@ -15,16 +15,6 @@ 2.9.0 - - full - true - - - - full - true - - diff --git a/src/IBM.WatsonDeveloperCloud.TextToSpeech.v1/TextToSpeechService.cs b/src/IBM.WatsonDeveloperCloud.TextToSpeech.v1/TextToSpeechService.cs index 8ed47d7305..601ad94e76 100644 --- a/src/IBM.WatsonDeveloperCloud.TextToSpeech.v1/TextToSpeechService.cs +++ b/src/IBM.WatsonDeveloperCloud.TextToSpeech.v1/TextToSpeechService.cs @@ -38,6 +38,7 @@ public TextToSpeechService() : base(SERVICE_NAME, URL) this.Endpoint = URL; } + public TextToSpeechService(string userName, string password) : this() { if (string.IsNullOrEmpty(userName)) @@ -48,6 +49,7 @@ public TextToSpeechService(string userName, string password) : this() this.SetCredential(userName, password); } + public TextToSpeechService(TokenOptions options) : this() { @@ -79,6 +81,9 @@ public TextToSpeechService(IClient httpClient) : this() /// Gets information about the specified voice. The information includes the name, language, gender, and other /// details about the voice. Specify a customization ID to obtain information for that custom voice model of the /// specified voice. To list information about all available voices, use the **List voices** method. + /// + /// **See also:** [Specifying a + /// voice](https://console.bluemix.net/docs/services/text-to-speech/http.html#voices). /// /// The voice for which information is to be returned. /// The customization ID (GUID) of a custom voice model for which information is @@ -95,14 +100,14 @@ public Voice GetVoice(string voice, string customizationId = null, Dictionary /// Custom data object to pass data including custom request headers. /// Voices @@ -138,14 +146,14 @@ public Voices ListVoices(Dictionary customData = null) try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/voices"); @@ -168,15 +176,16 @@ public Voices ListVoices(Dictionary customData = null) /// /// Synthesizes text to spoken audio, returning the synthesized audio stream as an array of bytes. You can pass /// a maximum of 5 KB of text. Use the `Accept` header or the `accept` query parameter to specify the requested - /// format (MIME type) of the response audio. By default, the service uses `audio/ogg;codecs=opus`. For detailed - /// information about the supported audio formats and sampling rates, see [Specifying an audio - /// format](https://console.bluemix.net/docs/services/text-to-speech/http.html#format). + /// format (MIME type) of the response audio. By default, the service uses `audio/ogg;codecs=opus`. /// /// If a request includes invalid query parameters, the service returns a `Warnings` response header that /// provides messages about the invalid parameters. The warning includes a descriptive message and a list of /// invalid argument strings. For example, a message such as `"Unknown arguments:"` or `"Unknown url query /// arguments:"` followed by a list of the form `"invalid_arg_1, invalid_arg_2."` The request succeeds despite /// the warnings. + /// + /// **See also:** [Synthesizing text to + /// audio](https://console.bluemix.net/docs/services/text-to-speech/http.html#synthesize). /// /// A `Text` object that provides the text to synthesize. Specify either plain text or a /// subset of SSML. Pass a maximum of 5 KB of text. @@ -201,14 +210,14 @@ public System.IO.MemoryStream Synthesize(Text text, string accept = null, string try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/synthesize"); @@ -238,6 +247,9 @@ public System.IO.MemoryStream Synthesize(Text text, string accept = null, string /// language of that voice or for a specific custom voice model to see the translation for that voice model. /// /// **Note:** This method is currently a beta release. + /// + /// **See also:** [Querying a word from a + /// language](https://console.bluemix.net/docs/services/text-to-speech/custom-entries.html#cuWordsQueryLanguage). /// /// The word for which the pronunciation is requested. /// A voice that specifies the language in which the pronunciation is to be returned. All @@ -261,14 +273,14 @@ public Pronunciation GetPronunciation(string text, string voice = null, string f try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/pronunciation"); @@ -302,6 +314,9 @@ public Pronunciation GetPronunciation(string text, string voice = null, string f /// whose credentials are used to create it. /// /// **Note:** This method is currently a beta release. + /// + /// **See also:** [Creating a custom + /// model](https://console.bluemix.net/docs/services/text-to-speech/custom-models.html#cuModelsCreate). /// /// A `CreateVoiceModel` object that contains information about the new custom /// voice model. @@ -315,14 +330,14 @@ public VoiceModel CreateVoiceModel(CreateVoiceModel createVoiceModel, Dictionary try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/customizations"); @@ -349,6 +364,9 @@ public VoiceModel CreateVoiceModel(CreateVoiceModel createVoiceModel, Dictionary /// a model to delete it. /// /// **Note:** This method is currently a beta release. + /// + /// **See also:** [Deleting a custom + /// model](https://console.bluemix.net/docs/services/text-to-speech/custom-models.html#cuModelsDelete). /// /// The customization ID (GUID) of the custom voice model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -362,14 +380,14 @@ public BaseModel DeleteVoiceModel(string customizationId, Dictionary /// The customization ID (GUID) of the custom voice model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -409,14 +430,14 @@ public VoiceModel GetVoiceModel(string customizationId, Dictionary /// The language for which custom voice models that are owned by the requesting service /// credentials are to be returned. Omit the parameter to see all custom voice models that are owned by the @@ -456,14 +480,14 @@ public VoiceModels ListVoiceModels(string language = null, Dictionary /// The customization ID (GUID) of the custom voice model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -511,14 +538,14 @@ public BaseModel UpdateVoiceModel(string customizationId, UpdateVoiceModel updat try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/customizations/{customizationId}"); @@ -546,6 +573,12 @@ public BaseModel UpdateVoiceModel(string customizationId, UpdateVoiceModel updat /// model to add a word to it. /// /// **Note:** This method is currently a beta release. + /// + /// **See also:** + /// * [Adding a single word to a custom + /// model](https://console.bluemix.net/docs/services/text-to-speech/custom-entries.html#cuWordAdd) + /// * [Adding words to a Japanese custom + /// model](https://console.bluemix.net/docs/services/text-to-speech/custom-entries.html#cuJapaneseAdd). /// /// The customization ID (GUID) of the custom voice model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -565,14 +598,14 @@ public BaseModel AddWord(string customizationId, string word, Translation transl try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PutAsync($"{this.Endpoint}/v1/customizations/{customizationId}/words/{word}"); @@ -601,6 +634,12 @@ public BaseModel AddWord(string customizationId, string word, Translation transl /// a model to add words to it. /// /// **Note:** This method is currently a beta release. + /// + /// **See also:** + /// * [Adding multiple words to a custom + /// model](https://console.bluemix.net/docs/services/text-to-speech/custom-entries.html#cuWordsAdd) + /// * [Adding words to a Japanese custom + /// model](https://console.bluemix.net/docs/services/text-to-speech/custom-entries.html#cuJapaneseAdd). /// /// The customization ID (GUID) of the custom voice model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -618,14 +657,14 @@ public BaseModel AddWords(string customizationId, Words customWords, Dictionary< try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v1/customizations/{customizationId}/words"); @@ -652,6 +691,9 @@ public BaseModel AddWords(string customizationId, Words customWords, Dictionary< /// the service that owns a model to delete its words. /// /// **Note:** This method is currently a beta release. + /// + /// **See also:** [Deleting a word from a custom + /// model](https://console.bluemix.net/docs/services/text-to-speech/custom-entries.html#cuWordDelete). /// /// The customization ID (GUID) of the custom voice model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -668,14 +710,14 @@ public BaseModel DeleteWord(string customizationId, string word, Dictionary /// The customization ID (GUID) of the custom voice model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -718,14 +763,14 @@ public Translation GetWord(string customizationId, string word, Dictionary /// The customization ID (GUID) of the custom voice model. You must make the /// request with service credentials created for the instance of the service that owns the custom model. @@ -765,14 +813,14 @@ public Words ListWords(string customizationId, Dictionary custom try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/customizations/{customizationId}/words"); @@ -799,7 +847,9 @@ public Words ListWords(string customizationId, Dictionary custom /// of the service that was used to associate the customer ID with the data. /// /// You associate a customer ID with data by passing the `X-Watson-Metadata` header with a request that passes - /// the data. For more information about customer IDs and about using this method, see [Information + /// the data. + /// + /// **See also:** [Information /// security](https://console.bluemix.net/docs/services/text-to-speech/information-security.html). /// /// The customer ID for which all data is to be deleted. @@ -813,14 +863,14 @@ public BaseModel DeleteUserData(string customerId, Dictionary cu try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.DeleteAsync($"{this.Endpoint}/v1/user_data"); diff --git a/src/IBM.WatsonDeveloperCloud.ToneAnalyzer.v3/IBM.WatsonDeveloperCloud.ToneAnalyzer.v3.csproj b/src/IBM.WatsonDeveloperCloud.ToneAnalyzer.v3/IBM.WatsonDeveloperCloud.ToneAnalyzer.v3.csproj index 3095984c70..e7339a5706 100644 --- a/src/IBM.WatsonDeveloperCloud.ToneAnalyzer.v3/IBM.WatsonDeveloperCloud.ToneAnalyzer.v3.csproj +++ b/src/IBM.WatsonDeveloperCloud.ToneAnalyzer.v3/IBM.WatsonDeveloperCloud.ToneAnalyzer.v3.csproj @@ -15,16 +15,6 @@ 2.9.0 - - full - true - - - - full - true - - diff --git a/src/IBM.WatsonDeveloperCloud.ToneAnalyzer.v3/ToneAnalyzerService.cs b/src/IBM.WatsonDeveloperCloud.ToneAnalyzer.v3/ToneAnalyzerService.cs index c0c98123ca..2b9e016bd7 100644 --- a/src/IBM.WatsonDeveloperCloud.ToneAnalyzer.v3/ToneAnalyzerService.cs +++ b/src/IBM.WatsonDeveloperCloud.ToneAnalyzer.v3/ToneAnalyzerService.cs @@ -43,6 +43,7 @@ public ToneAnalyzerService() : base(SERVICE_NAME, URL) this.Endpoint = URL; } + public ToneAnalyzerService(string userName, string password, string versionDate) : this() { if (string.IsNullOrEmpty(userName)) @@ -57,6 +58,7 @@ public ToneAnalyzerService(string userName, string password, string versionDate) VersionDate = versionDate; } + public ToneAnalyzerService(TokenOptions options, string versionDate) : this() { @@ -103,6 +105,9 @@ public ToneAnalyzerService(IClient httpClient) : this() /// character set). When specifying a content type of plain text or HTML, include the `charset` parameter to /// indicate the character encoding of the input text; for example: `Content-Type: text/plain;charset=utf-8`. /// For `text/html`, the service removes HTML tags and analyzes only the textual content. + /// + /// **See also:** [Using the general-purpose + /// endpoint](https://console.bluemix.net/docs/services/tone-analyzer/using-tone.html#using-the-general-purpose-endpoint). /// /// JSON, plain text, or HTML input that contains the content to be analyzed. For JSON /// input, provide an object of type `ToneInput`. @@ -143,14 +148,14 @@ public ToneAnalysis Tone(ToneInput toneInput, string contentType, bool? sentence try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v3/tone"); @@ -190,9 +195,11 @@ public ToneAnalysis Tone(ToneInput toneInput, string contentType, bool? sentence /// If you submit more than 50 utterances, the service returns a warning for the overall content and analyzes /// only the first 50 utterances. If you submit a single utterance that contains more than 500 characters, the /// service returns an error for that utterance and does not analyze the utterance. The request fails if all - /// utterances have more than 500 characters. + /// utterances have more than 500 characters. Per the JSON specification, the default character encoding for + /// JSON content is effectively always UTF-8. /// - /// Per the JSON specification, the default character encoding for JSON content is effectively always UTF-8. + /// **See also:** [Using the customer-engagement + /// endpoint](https://console.bluemix.net/docs/services/tone-analyzer/using-tone-chat.html#using-the-customer-engagement-endpoint). /// /// An object that contains the content to be analyzed. /// The language of the input text for the request: English or French. Regional @@ -218,14 +225,14 @@ public UtteranceAnalyses ToneChat(ToneChatInput utterances, string contentLangua try { - IClient client; - if(_tokenManager == null) + IClient client = null; + if(_tokenManager != null) { - client = this.Client.WithAuthentication(this.UserName, this.Password); + client = this.Client.WithAuthentication(_tokenManager.GetToken()); } else { - client = this.Client.WithAuthentication(_tokenManager.GetToken()); + client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.PostAsync($"{this.Endpoint}/v3/tone_chat"); diff --git a/src/IBM.WatsonDeveloperCloud.VisualRecognition.v3/IBM.WatsonDeveloperCloud.VisualRecognition.v3.csproj b/src/IBM.WatsonDeveloperCloud.VisualRecognition.v3/IBM.WatsonDeveloperCloud.VisualRecognition.v3.csproj index d5281f0b95..39c3870a30 100644 --- a/src/IBM.WatsonDeveloperCloud.VisualRecognition.v3/IBM.WatsonDeveloperCloud.VisualRecognition.v3.csproj +++ b/src/IBM.WatsonDeveloperCloud.VisualRecognition.v3/IBM.WatsonDeveloperCloud.VisualRecognition.v3.csproj @@ -15,16 +15,6 @@ 2.9.0 - - full - true - - - - full - true - - diff --git a/src/IBM.WatsonDeveloperCloud.VisualRecognition.v3/IVisualRecognitionService.cs b/src/IBM.WatsonDeveloperCloud.VisualRecognition.v3/IVisualRecognitionService.cs index 52c85ba761..0d9f1fd41d 100644 --- a/src/IBM.WatsonDeveloperCloud.VisualRecognition.v3/IVisualRecognitionService.cs +++ b/src/IBM.WatsonDeveloperCloud.VisualRecognition.v3/IVisualRecognitionService.cs @@ -24,9 +24,12 @@ public partial interface IVisualRecognitionService { ClassifiedImages Classify(System.IO.FileStream imagesFile = null, string acceptLanguage = null, string url = null, float? threshold = null, List owners = null, List classifierIds = null, string imagesFileContentType = null, Dictionary customData = null); DetectedFaces DetectFaces(System.IO.FileStream imagesFile = null, string url = null, string imagesFileContentType = null, Dictionary customData = null); + Classifier CreateClassifier(string name, System.IO.FileStream classnamePositiveExamples, System.IO.FileStream negativeExamples = null, Dictionary customData = null); BaseModel DeleteClassifier(string classifierId, Dictionary customData = null); Classifier GetClassifier(string classifierId, Dictionary customData = null); Classifiers ListClassifiers(bool? verbose = null, Dictionary customData = null); + Classifier UpdateClassifier(string classifierId, System.IO.FileStream classnamePositiveExamples = null, System.IO.FileStream negativeExamples = null, Dictionary customData = null); + System.IO.MemoryStream GetCoreMlModel(string classifierId, Dictionary customData = null); BaseModel DeleteUserData(string customerId, Dictionary customData = null); } } diff --git a/src/IBM.WatsonDeveloperCloud.VisualRecognition.v3/Model/Classifier.cs b/src/IBM.WatsonDeveloperCloud.VisualRecognition.v3/Model/Classifier.cs index 1fa32b1e2d..b5b2da21fe 100644 --- a/src/IBM.WatsonDeveloperCloud.VisualRecognition.v3/Model/Classifier.cs +++ b/src/IBM.WatsonDeveloperCloud.VisualRecognition.v3/Model/Classifier.cs @@ -90,7 +90,7 @@ public enum StatusEnum [JsonProperty("core_ml_enabled", NullValueHandling = NullValueHandling.Ignore)] public bool? CoreMlEnabled { get; set; } /// - /// If classifier training has failed, this field may explain why. + /// If classifier training has failed, this field might explain why. /// [JsonProperty("explanation", NullValueHandling = NullValueHandling.Ignore)] public string Explanation { get; set; } @@ -98,7 +98,7 @@ public enum StatusEnum /// Date and time in Coordinated Universal Time (UTC) that the classifier was created. /// [JsonProperty("created", NullValueHandling = NullValueHandling.Ignore)] - public DateTime? Created { get; set; } + public DateTime Created { get; set; } /// /// Classes that define a classifier. /// @@ -110,14 +110,14 @@ public enum StatusEnum /// compatibility. /// [JsonProperty("retrained", NullValueHandling = NullValueHandling.Ignore)] - public DateTime? Retrained { get; set; } + public DateTime Retrained { get; set; } /// /// Date and time in Coordinated Universal Time (UTC) that the classifier was most recently updated. The field /// matches either `retrained` or `created`. Returned when verbose=`true`. Might not be returned by some /// requests. /// [JsonProperty("updated", NullValueHandling = NullValueHandling.Ignore)] - public DateTime? Updated { get; set; } + public DateTime Updated { get; set; } } } diff --git a/src/IBM.WatsonDeveloperCloud.VisualRecognition.v3/VisualRecognitionService.cs b/src/IBM.WatsonDeveloperCloud.VisualRecognition.v3/VisualRecognitionService.cs index 7bb12709ba..9602885abe 100644 --- a/src/IBM.WatsonDeveloperCloud.VisualRecognition.v3/VisualRecognitionService.cs +++ b/src/IBM.WatsonDeveloperCloud.VisualRecognition.v3/VisualRecognitionService.cs @@ -45,17 +45,7 @@ public VisualRecognitionService() : base(SERVICE_NAME, URL) this.Endpoint = URL; } - public VisualRecognitionService(string apikey, string versionDate) : this() - { - if (string.IsNullOrEmpty(apikey)) - throw new ArgumentNullException(nameof(apikey)); - - this.SetCredential(apikey); - if(string.IsNullOrEmpty(versionDate)) - throw new ArgumentNullException("versionDate cannot be null."); - - VersionDate = versionDate; - } + public VisualRecognitionService(TokenOptions options, string versionDate) : this() { @@ -175,19 +165,14 @@ public ClassifiedImages Classify(System.IO.FileStream imagesFile = null, string formData.Add(classifierIdsContent, "classifier_ids"); } - IClient client; - if(_tokenManager == null) - { - client = this.Client; - } - else + IClient client = null; + if(_tokenManager != null) { client = this.Client.WithAuthentication(_tokenManager.GetToken()); } var restRequest = client.PostAsync($"{this.Endpoint}/v3/classify"); restRequest.WithArgument("version", VersionDate); - restRequest.WithArgument("api_key", ApiKey); if (!string.IsNullOrEmpty(acceptLanguage)) restRequest.WithHeader("Accept-Language", acceptLanguage); restRequest.WithBodyContent(formData); @@ -263,19 +248,14 @@ public DetectedFaces DetectFaces(System.IO.FileStream imagesFile = null, string formData.Add(urlContent, "url"); } - IClient client; - if(_tokenManager == null) - { - client = this.Client; - } - else + IClient client = null; + if(_tokenManager != null) { client = this.Client.WithAuthentication(_tokenManager.GetToken()); } var restRequest = client.PostAsync($"{this.Endpoint}/v3/detect_faces"); restRequest.WithArgument("version", VersionDate); - restRequest.WithArgument("api_key", ApiKey); restRequest.WithBodyContent(formData); if (customData != null) restRequest.WithCustomData(customData); @@ -291,6 +271,97 @@ public DetectedFaces DetectFaces(System.IO.FileStream imagesFile = null, string return result; } + /// + /// 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. + /// + /// 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 name of the new classifier. Encode special characters in UTF-8. + /// A .zip file of images that depict the visual subject of a class in + /// the new classifier. You can include more than one positive example file in a call. + /// + /// Specify the parameter name by appending `_positive_examples` to the class name. For example, + /// `goldenretriever_positive_examples` creates the class **goldenretriever**. + /// + /// Include at least 10 images in .jpg or .png format. The minimum recommended image resolution is 32X32 pixels. + /// The maximum number of images is 10,000 images or 100 MB per .zip file. + /// + /// Encode special characters in the file name in UTF-8. + /// A .zip file of images that do not depict the visual subject of any of the + /// classes of the new classifier. Must contain a minimum of 10 images. + /// + /// Encode special characters in the file name in UTF-8. (optional) + /// Custom data object to pass data including custom request headers. + /// Classifier + public Classifier CreateClassifier(string name, System.IO.FileStream classnamePositiveExamples, System.IO.FileStream negativeExamples = null, Dictionary customData = null) + { + if (string.IsNullOrEmpty(name)) + throw new ArgumentNullException(nameof(name)); + if (classnamePositiveExamples == null) + throw new ArgumentNullException(nameof(classnamePositiveExamples)); + + if(string.IsNullOrEmpty(VersionDate)) + throw new ArgumentNullException("versionDate cannot be null."); + + Classifier result = null; + + try + { + var formData = new MultipartFormDataContent(); + + if (name != null) + { + var nameContent = new StringContent(name, Encoding.UTF8, HttpMediaType.TEXT_PLAIN); + nameContent.Headers.ContentType = null; + formData.Add(nameContent, "name"); + } + + if (classnamePositiveExamples != null) + { + var classnamePositiveExamplesContent = new ByteArrayContent((classnamePositiveExamples as Stream).ReadAllBytes()); + System.Net.Http.Headers.MediaTypeHeaderValue contentType; + System.Net.Http.Headers.MediaTypeHeaderValue.TryParse("application/octet-stream", out contentType); + classnamePositiveExamplesContent.Headers.ContentType = contentType; + formData.Add(classnamePositiveExamplesContent, "classname_positive_examples", classnamePositiveExamples.Name); + } + + if (negativeExamples != null) + { + var negativeExamplesContent = new ByteArrayContent((negativeExamples as Stream).ReadAllBytes()); + System.Net.Http.Headers.MediaTypeHeaderValue contentType; + System.Net.Http.Headers.MediaTypeHeaderValue.TryParse("application/octet-stream", out contentType); + negativeExamplesContent.Headers.ContentType = contentType; + formData.Add(negativeExamplesContent, "negative_examples", negativeExamples.Name); + } + + IClient client = null; + if(_tokenManager != null) + { + client = this.Client.WithAuthentication(_tokenManager.GetToken()); + } + var restRequest = client.PostAsync($"{this.Endpoint}/v3/classifiers"); + + restRequest.WithArgument("version", VersionDate); + restRequest.WithBodyContent(formData); + if (customData != null) + restRequest.WithCustomData(customData); + result = restRequest.As().Result; + if(result == null) + result = new Classifier(); + result.CustomData = restRequest.CustomData; + } + catch(AggregateException ae) + { + throw ae.Flatten(); + } + + return result; + } /// /// Delete a classifier. @@ -310,19 +381,14 @@ public BaseModel DeleteClassifier(string classifierId, Dictionary().Result; @@ -358,19 +424,14 @@ public Classifier GetClassifier(string classifierId, Dictionary try { - IClient client; - if(_tokenManager == null) - { - client = this.Client; - } - else + IClient client = null; + if(_tokenManager != null) { client = this.Client.WithAuthentication(_tokenManager.GetToken()); } var restRequest = client.GetAsync($"{this.Endpoint}/v3/classifiers/{classifierId}"); restRequest.WithArgument("version", VersionDate); - restRequest.WithArgument("api_key", ApiKey); if (customData != null) restRequest.WithCustomData(customData); result = restRequest.As().Result; @@ -403,19 +464,14 @@ public Classifiers ListClassifiers(bool? verbose = null, Dictionary + /// Update a classifier. + /// + /// Update a custom classifier by adding new positive or negative classes (examples) or by adding new images to + /// existing classes. You must supply at least one set of positive or negative examples. For details, see + /// [Updating custom + /// classifiers](https://console.bluemix.net/docs/services/visual-recognition/customizing.html#updating-custom-classifiers). + /// + /// 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. + /// + /// The ID of the classifier. + /// A .zip file of images that depict the visual subject of a class in + /// the classifier. The positive examples create or update classes in the classifier. You can include more than + /// one positive example file in a call. + /// + /// Specify the parameter name by appending `_positive_examples` to the class name. For example, + /// `goldenretriever_positive_examples` creates the class `goldenretriever`. + /// + /// Include at least 10 images in .jpg or .png format. The minimum recommended image resolution is 32X32 pixels. + /// The maximum number of images is 10,000 images or 100 MB per .zip file. + /// + /// Encode special characters in the file name in UTF-8. (optional) + /// A .zip file of images that do not depict the visual subject of any of the + /// classes of the new classifier. Must contain a minimum of 10 images. + /// + /// Encode special characters in the file name in UTF-8. (optional) + /// Custom data object to pass data including custom request headers. + /// Classifier + public Classifier UpdateClassifier(string classifierId, System.IO.FileStream classnamePositiveExamples = null, System.IO.FileStream negativeExamples = null, Dictionary customData = null) + { + if (string.IsNullOrEmpty(classifierId)) + throw new ArgumentNullException(nameof(classifierId)); + + if(string.IsNullOrEmpty(VersionDate)) + throw new ArgumentNullException("versionDate cannot be null."); + + Classifier result = null; + + try + { + var formData = new MultipartFormDataContent(); + + if (classnamePositiveExamples != null) + { + var classnamePositiveExamplesContent = new ByteArrayContent((classnamePositiveExamples as Stream).ReadAllBytes()); + System.Net.Http.Headers.MediaTypeHeaderValue contentType; + System.Net.Http.Headers.MediaTypeHeaderValue.TryParse("application/octet-stream", out contentType); + classnamePositiveExamplesContent.Headers.ContentType = contentType; + formData.Add(classnamePositiveExamplesContent, "classname_positive_examples", classnamePositiveExamples.Name); + } + + if (negativeExamples != null) + { + var negativeExamplesContent = new ByteArrayContent((negativeExamples as Stream).ReadAllBytes()); + System.Net.Http.Headers.MediaTypeHeaderValue contentType; + System.Net.Http.Headers.MediaTypeHeaderValue.TryParse("application/octet-stream", out contentType); + negativeExamplesContent.Headers.ContentType = contentType; + formData.Add(negativeExamplesContent, "negative_examples", negativeExamples.Name); + } + + IClient client = null; + if(_tokenManager != null) + { + client = this.Client.WithAuthentication(_tokenManager.GetToken()); + } + var restRequest = client.PostAsync($"{this.Endpoint}/v3/classifiers/{classifierId}"); + + restRequest.WithArgument("version", VersionDate); + restRequest.WithBodyContent(formData); + if (customData != null) + restRequest.WithCustomData(customData); + result = restRequest.As().Result; + if(result == null) + result = new Classifier(); + result.CustomData = restRequest.CustomData; + } + catch(AggregateException ae) + { + throw ae.Flatten(); + } + + return result; + } + /// + /// Retrieve a Core ML model of a classifier. + /// + /// Download a Core ML model file (.mlmodel) of a custom classifier that returns "core_ml_enabled": + /// true in the classifier details. + /// + /// The ID of the classifier. + /// Custom data object to pass data including custom request headers. + /// System.IO.FileStream + public System.IO.MemoryStream GetCoreMlModel(string classifierId, Dictionary customData = null) + { + if (string.IsNullOrEmpty(classifierId)) + throw new ArgumentNullException(nameof(classifierId)); + + if(string.IsNullOrEmpty(VersionDate)) + throw new ArgumentNullException("versionDate cannot be null."); + + System.IO.MemoryStream result = null; + + try + { + IClient client = null; + if(_tokenManager != null) + { + client = this.Client.WithAuthentication(_tokenManager.GetToken()); + } + var restRequest = client.GetAsync($"{this.Endpoint}/v3/classifiers/{classifierId}/core_ml_model"); + + restRequest.WithArgument("version", VersionDate); + if (customData != null) + restRequest.WithCustomData(customData); + result = new System.IO.MemoryStream(restRequest.AsByteArray().Result); + } + catch(AggregateException ae) + { + throw ae.Flatten(); + } + + return result; + } /// /// Delete labeled data. /// @@ -458,19 +642,14 @@ public BaseModel DeleteUserData(string customerId, Dictionary cu try { - IClient client; - if(_tokenManager == null) - { - client = this.Client; - } - else + IClient client = null; + if(_tokenManager != null) { client = this.Client.WithAuthentication(_tokenManager.GetToken()); } var restRequest = client.DeleteAsync($"{this.Endpoint}/v3/user_data"); restRequest.WithArgument("version", VersionDate); - restRequest.WithArgument("api_key", ApiKey); if (!string.IsNullOrEmpty(customerId)) restRequest.WithArgument("customer_id", customerId); if (customData != null)