From 41a53012f4312b02d97d2e0a7261bcfd1f9a65b2 Mon Sep 17 00:00:00 2001 From: adxsdknet Date: Mon, 29 Apr 2019 23:05:05 +0000 Subject: [PATCH] .NET SDK Resource Provider:'Runtime' REST Spec PR 'https://github.com/Azure/azure-rest-api-specs/pull/5793' REST Spec PR Author 'moabba' REST Spec PR Last commit --- .../Runtime/Generated/ILUISRuntimeClient.cs | 4 +- .../LUIS/Runtime/Generated/IPrediction.cs | 70 --- .../Generated/IPredictionOperations.cs | 104 ++++ .../Runtime/Generated/LUISRuntimeClient.cs | 8 +- ...CompositeEntityModel.cs => DynamicList.cs} | 59 +-- .../Runtime/Generated/Models/EntityModel.cs | 110 ---- .../Generated/Models/EntityWithResolution.cs | 76 --- .../Generated/Models/EntityWithScore.cs | 80 --- .../Models/{APIError.cs => Error.cs} | 42 +- .../{CompositeChildModel.cs => ErrorBody.cs} | 40 +- ...APIErrorException.cs => ErrorException.cs} | 18 +- .../Generated/Models/ExternalEntity.cs | 93 ++++ .../Models/{IntentModel.cs => Intent.cs} | 44 +- .../Runtime/Generated/Models/LuisResult.cs | 157 ------ .../Runtime/Generated/Models/Prediction.cs | 140 ++++++ .../Generated/Models/PredictionRequest.cs | 114 +++++ .../Models/PredictionRequestOptions.cs | 64 +++ .../Generated/Models/PredictionResponse.cs | 82 +++ .../Runtime/Generated/Models/RequestList.cs | 84 ++++ .../Runtime/Generated/Models/Sentiment.cs | 35 +- .../LUIS/Runtime/Generated/Prediction.cs | 278 ----------- .../Runtime/Generated/PredictionExtensions.cs | 65 --- .../Runtime/Generated/PredictionOperations.cs | 468 ++++++++++++++++++ .../PredictionOperationsExtensions.cs | 97 ++++ .../Generated/SdkInfo_LUISRuntimeClient.cs | 2 +- 25 files changed, 1371 insertions(+), 963 deletions(-) delete mode 100644 src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/IPrediction.cs create mode 100644 src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/IPredictionOperations.cs rename src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/{CompositeEntityModel.cs => DynamicList.cs} (52%) delete mode 100644 src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/EntityModel.cs delete mode 100644 src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/EntityWithResolution.cs delete mode 100644 src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/EntityWithScore.cs rename src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/{APIError.cs => Error.cs} (51%) rename src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/{CompositeChildModel.cs => ErrorBody.cs} (61%) rename src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/{APIErrorException.cs => ErrorException.cs} (71%) create mode 100644 src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/ExternalEntity.cs rename src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/{IntentModel.cs => Intent.cs} (53%) delete mode 100644 src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/LuisResult.cs create mode 100644 src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/Prediction.cs create mode 100644 src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/PredictionRequest.cs create mode 100644 src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/PredictionRequestOptions.cs create mode 100644 src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/PredictionResponse.cs create mode 100644 src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/RequestList.cs delete mode 100644 src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Prediction.cs delete mode 100644 src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/PredictionExtensions.cs create mode 100644 src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/PredictionOperations.cs create mode 100644 src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/PredictionOperationsExtensions.cs diff --git a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/ILUISRuntimeClient.cs b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/ILUISRuntimeClient.cs index 98ee3c0d7806..daa9feb8a1e2 100644 --- a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/ILUISRuntimeClient.cs +++ b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/ILUISRuntimeClient.cs @@ -46,9 +46,9 @@ public partial interface ILUISRuntimeClient : System.IDisposable /// - /// Gets the IPrediction. + /// Gets the IPredictionOperations. /// - IPrediction Prediction { get; } + IPredictionOperations Prediction { get; } } } diff --git a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/IPrediction.cs b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/IPrediction.cs deleted file mode 100644 index 2210ef103283..000000000000 --- a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/IPrediction.cs +++ /dev/null @@ -1,70 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime -{ - using Microsoft.Rest; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Prediction operations. - /// - public partial interface IPrediction - { - /// - /// Gets predictions for a given utterance, in the form of intents and - /// entities. The current maximum query size is 500 characters. - /// - /// - /// The LUIS application ID (Guid). - /// - /// - /// The utterance to predict. - /// - /// - /// The timezone offset for the location of the request. - /// - /// - /// If true, return all intents instead of just the top scoring intent. - /// - /// - /// Use the staging endpoint slot. - /// - /// - /// Enable spell checking. - /// - /// - /// The subscription key to use when enabling Bing spell check - /// - /// - /// Log query (default is true) - /// - /// - /// The headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - Task> ResolveWithHttpMessagesAsync(System.Guid appId, string query, double? timezoneOffset = default(double?), bool? verbose = default(bool?), bool? staging = default(bool?), bool? spellCheck = default(bool?), string bingSpellCheckSubscriptionKey = default(string), bool? log = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} diff --git a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/IPredictionOperations.cs b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/IPredictionOperations.cs new file mode 100644 index 000000000000..b4ae468218b4 --- /dev/null +++ b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/IPredictionOperations.cs @@ -0,0 +1,104 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime +{ + using Microsoft.Rest; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PredictionOperations operations. + /// + public partial interface IPredictionOperations + { + /// + /// Gets the predictions for an application version. + /// + /// + /// The application ID. + /// + /// + /// The application version ID. + /// + /// + /// The prediction request parameters. + /// + /// + /// Indicates whether to get extra metadata for the entities + /// predictions or not. + /// + /// + /// Indicates whether to return all the intents in the response or just + /// the top intent. + /// + /// + /// Indicates whether to log the endpoint query or not. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetVersionPredictionWithHttpMessagesAsync(System.Guid appId, string versionId, PredictionRequest predictionRequest, bool? verbose = default(bool?), bool? showAllIntents = default(bool?), bool? log = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the predictions for an application slot. + /// + /// + /// The application ID. + /// + /// + /// The application slot name. + /// + /// + /// The prediction request parameters. + /// + /// + /// Indicates whether to get extra metadata for the entities + /// predictions or not. + /// + /// + /// Indicates whether to return all the intents in the response or just + /// the top intent. + /// + /// + /// Indicates whether to log the endpoint query or not. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetSlotPredictionWithHttpMessagesAsync(System.Guid appId, string slotName, PredictionRequest predictionRequest, bool? verbose = default(bool?), bool? showAllIntents = default(bool?), bool? log = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/LUISRuntimeClient.cs b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/LUISRuntimeClient.cs index ba6c82eacffd..f0cb9750dbea 100644 --- a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/LUISRuntimeClient.cs +++ b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/LUISRuntimeClient.cs @@ -48,9 +48,9 @@ public partial class LUISRuntimeClient : ServiceClient, ILUIS public ServiceClientCredentials Credentials { get; private set; } /// - /// Gets the IPrediction. + /// Gets the IPredictionOperations. /// - public virtual IPrediction Prediction { get; private set; } + public virtual IPredictionOperations Prediction { get; private set; } /// /// Initializes a new instance of the LUISRuntimeClient class. @@ -179,8 +179,8 @@ public LUISRuntimeClient(ServiceClientCredentials credentials, HttpClientHandler /// private void Initialize() { - Prediction = new Prediction(this); - BaseUri = "{Endpoint}/luis/v2.0"; + Prediction = new PredictionOperations(this); + BaseUri = "{Endpoint}/luis/v3.0-preview"; SerializationSettings = new JsonSerializerSettings { Formatting = Newtonsoft.Json.Formatting.Indented, diff --git a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/CompositeEntityModel.cs b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/DynamicList.cs similarity index 52% rename from src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/CompositeEntityModel.cs rename to src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/DynamicList.cs index e321b0319f45..055d3d9e8cec 100644 --- a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/CompositeEntityModel.cs +++ b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/DynamicList.cs @@ -17,30 +17,29 @@ namespace Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.Models using System.Linq; /// - /// LUIS Composite Entity. + /// Defines an extension for a list entity. /// - public partial class CompositeEntityModel + public partial class DynamicList { /// - /// Initializes a new instance of the CompositeEntityModel class. + /// Initializes a new instance of the DynamicList class. /// - public CompositeEntityModel() + public DynamicList() { CustomInit(); } /// - /// Initializes a new instance of the CompositeEntityModel class. + /// Initializes a new instance of the DynamicList class. /// - /// Type/name of parent entity. - /// Value for composite entity extracted by - /// LUIS. - /// Child entities. - public CompositeEntityModel(string parentType, string value, IList children) + /// The name of the list entity to + /// extend. + /// The lists to append on the extended list + /// entity. + public DynamicList(string listEntityName, IList requestLists) { - ParentType = parentType; - Value = value; - Children = children; + ListEntityName = listEntityName; + RequestLists = requestLists; CustomInit(); } @@ -50,22 +49,16 @@ public CompositeEntityModel(string parentType, string value, IList - /// Gets or sets type/name of parent entity. + /// Gets or sets the name of the list entity to extend. /// - [JsonProperty(PropertyName = "parentType")] - public string ParentType { get; set; } + [JsonProperty(PropertyName = "listEntityName")] + public string ListEntityName { get; set; } /// - /// Gets or sets value for composite entity extracted by LUIS. + /// Gets or sets the lists to append on the extended list entity. /// - [JsonProperty(PropertyName = "value")] - public string Value { get; set; } - - /// - /// Gets or sets child entities. - /// - [JsonProperty(PropertyName = "children")] - public IList Children { get; set; } + [JsonProperty(PropertyName = "requestLists")] + public IList RequestLists { get; set; } /// /// Validate the object. @@ -75,21 +68,17 @@ public CompositeEntityModel(string parentType, string value, IList public virtual void Validate() { - if (ParentType == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "ParentType"); - } - if (Value == null) + if (ListEntityName == null) { - throw new ValidationException(ValidationRules.CannotBeNull, "Value"); + throw new ValidationException(ValidationRules.CannotBeNull, "ListEntityName"); } - if (Children == null) + if (RequestLists == null) { - throw new ValidationException(ValidationRules.CannotBeNull, "Children"); + throw new ValidationException(ValidationRules.CannotBeNull, "RequestLists"); } - if (Children != null) + if (RequestLists != null) { - foreach (var element in Children) + foreach (var element in RequestLists) { if (element != null) { diff --git a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/EntityModel.cs b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/EntityModel.cs deleted file mode 100644 index b1b0649a90f3..000000000000 --- a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/EntityModel.cs +++ /dev/null @@ -1,110 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// An entity extracted from the utterance. - /// - public partial class EntityModel - { - /// - /// Initializes a new instance of the EntityModel class. - /// - public EntityModel() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the EntityModel class. - /// - /// Name of the entity, as defined in - /// LUIS. - /// Type of the entity, as defined in LUIS. - /// The position of the first character of the - /// matched entity within the utterance. - /// The position of the last character of the - /// matched entity within the utterance. - /// Unmatched properties from the - /// message are deserialized this collection - public EntityModel(string entity, string type, int startIndex, int endIndex, IDictionary additionalProperties = default(IDictionary)) - { - AdditionalProperties = additionalProperties; - Entity = entity; - Type = type; - StartIndex = startIndex; - EndIndex = endIndex; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets unmatched properties from the message are deserialized - /// this collection - /// - [JsonExtensionData] - public IDictionary AdditionalProperties { get; set; } - - /// - /// Gets or sets name of the entity, as defined in LUIS. - /// - [JsonProperty(PropertyName = "entity")] - public string Entity { get; set; } - - /// - /// Gets or sets type of the entity, as defined in LUIS. - /// - [JsonProperty(PropertyName = "type")] - public string Type { get; set; } - - /// - /// Gets or sets the position of the first character of the matched - /// entity within the utterance. - /// - [JsonProperty(PropertyName = "startIndex")] - public int StartIndex { get; set; } - - /// - /// Gets or sets the position of the last character of the matched - /// entity within the utterance. - /// - [JsonProperty(PropertyName = "endIndex")] - public int EndIndex { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Entity == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Entity"); - } - if (Type == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Type"); - } - } - } -} diff --git a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/EntityWithResolution.cs b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/EntityWithResolution.cs deleted file mode 100644 index c74d84f2a09e..000000000000 --- a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/EntityWithResolution.cs +++ /dev/null @@ -1,76 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - public partial class EntityWithResolution : EntityModel - { - /// - /// Initializes a new instance of the EntityWithResolution class. - /// - public EntityWithResolution() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the EntityWithResolution class. - /// - /// Name of the entity, as defined in - /// LUIS. - /// Type of the entity, as defined in LUIS. - /// The position of the first character of the - /// matched entity within the utterance. - /// The position of the last character of the - /// matched entity within the utterance. - /// Resolution values for pre-built LUIS - /// entities. - /// Unmatched properties from the - /// message are deserialized this collection - public EntityWithResolution(string entity, string type, int startIndex, int endIndex, object resolution, IDictionary additionalProperties = default(IDictionary)) - : base(entity, type, startIndex, endIndex, additionalProperties) - { - Resolution = resolution; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets resolution values for pre-built LUIS entities. - /// - [JsonProperty(PropertyName = "resolution")] - public object Resolution { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public override void Validate() - { - base.Validate(); - if (Resolution == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Resolution"); - } - } - } -} diff --git a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/EntityWithScore.cs b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/EntityWithScore.cs deleted file mode 100644 index 74000ad01040..000000000000 --- a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/EntityWithScore.cs +++ /dev/null @@ -1,80 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.Models -{ - using Microsoft.Rest; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - public partial class EntityWithScore : EntityModel - { - /// - /// Initializes a new instance of the EntityWithScore class. - /// - public EntityWithScore() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the EntityWithScore class. - /// - /// Name of the entity, as defined in - /// LUIS. - /// Type of the entity, as defined in LUIS. - /// The position of the first character of the - /// matched entity within the utterance. - /// The position of the last character of the - /// matched entity within the utterance. - /// Associated prediction score for the intent - /// (float). - /// Unmatched properties from the - /// message are deserialized this collection - public EntityWithScore(string entity, string type, int startIndex, int endIndex, double score, IDictionary additionalProperties = default(IDictionary)) - : base(entity, type, startIndex, endIndex, additionalProperties) - { - Score = score; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets associated prediction score for the intent (float). - /// - [JsonProperty(PropertyName = "score")] - public double Score { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public override void Validate() - { - base.Validate(); - if (Score > 1) - { - throw new ValidationException(ValidationRules.InclusiveMaximum, "Score", 1); - } - if (Score < 0) - { - throw new ValidationException(ValidationRules.InclusiveMinimum, "Score", 0); - } - } - } -} diff --git a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/APIError.cs b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/Error.cs similarity index 51% rename from src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/APIError.cs rename to src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/Error.cs index 756c598cfeb4..080625fde057 100644 --- a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/APIError.cs +++ b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/Error.cs @@ -10,31 +10,29 @@ namespace Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.Models { + using Microsoft.Rest; using Newtonsoft.Json; using System.Linq; /// - /// Error information returned by the API + /// Represents the error that occurred. /// - public partial class APIError + public partial class Error { /// - /// Initializes a new instance of the APIError class. + /// Initializes a new instance of the Error class. /// - public APIError() + public Error() { CustomInit(); } /// - /// Initializes a new instance of the APIError class. + /// Initializes a new instance of the Error class. /// - /// HTTP Status code - /// Cause of the error. - public APIError(string statusCode = default(string), string message = default(string)) + public Error(ErrorBody errorProperty) { - StatusCode = statusCode; - Message = message; + ErrorProperty = errorProperty; CustomInit(); } @@ -44,16 +42,26 @@ public APIError() partial void CustomInit(); /// - /// Gets or sets HTTP Status code /// - [JsonProperty(PropertyName = "statusCode")] - public string StatusCode { get; set; } + [JsonProperty(PropertyName = "error")] + public ErrorBody ErrorProperty { get; set; } /// - /// Gets or sets cause of the error. + /// Validate the object. /// - [JsonProperty(PropertyName = "message")] - public string Message { get; set; } - + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (ErrorProperty == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ErrorProperty"); + } + if (ErrorProperty != null) + { + ErrorProperty.Validate(); + } + } } } diff --git a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/CompositeChildModel.cs b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/ErrorBody.cs similarity index 61% rename from src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/CompositeChildModel.cs rename to src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/ErrorBody.cs index 51a2e9e51ae1..4fd7732945eb 100644 --- a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/CompositeChildModel.cs +++ b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/ErrorBody.cs @@ -15,27 +15,27 @@ namespace Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.Models using System.Linq; /// - /// Child entity in a LUIS Composite Entity. + /// Represents the definition of the error that occurred. /// - public partial class CompositeChildModel + public partial class ErrorBody { /// - /// Initializes a new instance of the CompositeChildModel class. + /// Initializes a new instance of the ErrorBody class. /// - public CompositeChildModel() + public ErrorBody() { CustomInit(); } /// - /// Initializes a new instance of the CompositeChildModel class. + /// Initializes a new instance of the ErrorBody class. /// - /// Type of child entity. - /// Value extracted by LUIS. - public CompositeChildModel(string type, string value) + /// The error code. + /// The error message. + public ErrorBody(string code, string message) { - Type = type; - Value = value; + Code = code; + Message = message; CustomInit(); } @@ -45,16 +45,16 @@ public CompositeChildModel(string type, string value) partial void CustomInit(); /// - /// Gets or sets type of child entity. + /// Gets or sets the error code. /// - [JsonProperty(PropertyName = "type")] - public string Type { get; set; } + [JsonProperty(PropertyName = "code")] + public string Code { get; set; } /// - /// Gets or sets value extracted by LUIS. + /// Gets or sets the error message. /// - [JsonProperty(PropertyName = "value")] - public string Value { get; set; } + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } /// /// Validate the object. @@ -64,13 +64,13 @@ public CompositeChildModel(string type, string value) /// public virtual void Validate() { - if (Type == null) + if (Code == null) { - throw new ValidationException(ValidationRules.CannotBeNull, "Type"); + throw new ValidationException(ValidationRules.CannotBeNull, "Code"); } - if (Value == null) + if (Message == null) { - throw new ValidationException(ValidationRules.CannotBeNull, "Value"); + throw new ValidationException(ValidationRules.CannotBeNull, "Message"); } } } diff --git a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/APIErrorException.cs b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/ErrorException.cs similarity index 71% rename from src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/APIErrorException.cs rename to src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/ErrorException.cs index 62d4cc50d14e..d2190339ae3b 100644 --- a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/APIErrorException.cs +++ b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/ErrorException.cs @@ -13,9 +13,9 @@ namespace Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.Models using Microsoft.Rest; /// - /// Exception thrown for an invalid response with APIError information. + /// Exception thrown for an invalid response with Error information. /// - public partial class APIErrorException : RestException + public partial class ErrorException : RestException { /// /// Gets information about the associated HTTP request. @@ -30,30 +30,30 @@ public partial class APIErrorException : RestException /// /// Gets or sets the body object. /// - public APIError Body { get; set; } + public Error Body { get; set; } /// - /// Initializes a new instance of the APIErrorException class. + /// Initializes a new instance of the ErrorException class. /// - public APIErrorException() + public ErrorException() { } /// - /// Initializes a new instance of the APIErrorException class. + /// Initializes a new instance of the ErrorException class. /// /// The exception message. - public APIErrorException(string message) + public ErrorException(string message) : this(message, null) { } /// - /// Initializes a new instance of the APIErrorException class. + /// Initializes a new instance of the ErrorException class. /// /// The exception message. /// Inner exception. - public APIErrorException(string message, System.Exception innerException) + public ErrorException(string message, System.Exception innerException) : base(message, innerException) { } diff --git a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/ExternalEntity.cs b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/ExternalEntity.cs new file mode 100644 index 000000000000..3fd3776311af --- /dev/null +++ b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/ExternalEntity.cs @@ -0,0 +1,93 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines a user perdicted entity that extends an already existing one. + /// + public partial class ExternalEntity + { + /// + /// Initializes a new instance of the ExternalEntity class. + /// + public ExternalEntity() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ExternalEntity class. + /// + /// The name of the entity to extend. + /// The start character index of the predicted + /// entity. + /// The length of the predicted + /// entity. + /// A user supplied custom resolution to + /// return as the entity's prediction. + public ExternalEntity(string entityName, int startIndex, int entityLength, object resolution = default(object)) + { + EntityName = entityName; + StartIndex = startIndex; + EntityLength = entityLength; + Resolution = resolution; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the entity to extend. + /// + [JsonProperty(PropertyName = "entityName")] + public string EntityName { get; set; } + + /// + /// Gets or sets the start character index of the predicted entity. + /// + [JsonProperty(PropertyName = "startIndex")] + public int StartIndex { get; set; } + + /// + /// Gets or sets the length of the predicted entity. + /// + [JsonProperty(PropertyName = "entityLength")] + public int EntityLength { get; set; } + + /// + /// Gets or sets a user supplied custom resolution to return as the + /// entity's prediction. + /// + [JsonProperty(PropertyName = "resolution")] + public object Resolution { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (EntityName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "EntityName"); + } + } + } +} diff --git a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/IntentModel.cs b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/Intent.cs similarity index 53% rename from src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/IntentModel.cs rename to src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/Intent.cs index 19d37e9edbe0..2d9756462cc3 100644 --- a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/IntentModel.cs +++ b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/Intent.cs @@ -10,34 +10,32 @@ namespace Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.Models { - using Microsoft.Rest; using Newtonsoft.Json; using System.Linq; /// - /// An intent detected from the utterance. + /// Represents an intent prediction. /// - public partial class IntentModel + public partial class Intent { /// - /// Initializes a new instance of the IntentModel class. + /// Initializes a new instance of the Intent class. /// - public IntentModel() + public Intent() { CustomInit(); } /// - /// Initializes a new instance of the IntentModel class. + /// Initializes a new instance of the Intent class. /// - /// Name of the intent, as defined in - /// LUIS. - /// Associated prediction score for the intent - /// (float). - public IntentModel(string intent = default(string), double? score = default(double?)) + /// The score of the fired intent. + /// The prediction of the dispatched + /// application. + public Intent(double? score = default(double?), Prediction childApp = default(Prediction)) { - Intent = intent; Score = score; + ChildApp = childApp; CustomInit(); } @@ -47,32 +45,28 @@ public IntentModel() partial void CustomInit(); /// - /// Gets or sets name of the intent, as defined in LUIS. + /// Gets or sets the score of the fired intent. /// - [JsonProperty(PropertyName = "intent")] - public string Intent { get; set; } + [JsonProperty(PropertyName = "score")] + public double? Score { get; set; } /// - /// Gets or sets associated prediction score for the intent (float). + /// Gets or sets the prediction of the dispatched application. /// - [JsonProperty(PropertyName = "score")] - public double? Score { get; set; } + [JsonProperty(PropertyName = "childApp")] + public Prediction ChildApp { get; set; } /// /// Validate the object. /// - /// + /// /// Thrown if validation fails /// public virtual void Validate() { - if (Score > 1) - { - throw new ValidationException(ValidationRules.InclusiveMaximum, "Score", 1); - } - if (Score < 0) + if (ChildApp != null) { - throw new ValidationException(ValidationRules.InclusiveMinimum, "Score", 0); + ChildApp.Validate(); } } } diff --git a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/LuisResult.cs b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/LuisResult.cs deleted file mode 100644 index afc0915de607..000000000000 --- a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/LuisResult.cs +++ /dev/null @@ -1,157 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.Models -{ - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - /// - /// Prediction, based on the input query, containing intent(s) and - /// entities. - /// - public partial class LuisResult - { - /// - /// Initializes a new instance of the LuisResult class. - /// - public LuisResult() - { - CustomInit(); - } - - /// - /// Initializes a new instance of the LuisResult class. - /// - /// The input utterance that was analyzed. - /// The corrected utterance (when spell - /// checking was enabled). - /// All the intents (and their score) that were - /// detected from utterance. - /// The entities extracted from the - /// utterance. - /// The composite entities extracted - /// from the utterance. - public LuisResult(string query = default(string), string alteredQuery = default(string), IntentModel topScoringIntent = default(IntentModel), IList intents = default(IList), IList entities = default(IList), IList compositeEntities = default(IList), Sentiment sentimentAnalysis = default(Sentiment), LuisResult connectedServiceResult = default(LuisResult)) - { - Query = query; - AlteredQuery = alteredQuery; - TopScoringIntent = topScoringIntent; - Intents = intents; - Entities = entities; - CompositeEntities = compositeEntities; - SentimentAnalysis = sentimentAnalysis; - ConnectedServiceResult = connectedServiceResult; - CustomInit(); - } - - /// - /// An initialization method that performs custom operations like setting defaults - /// - partial void CustomInit(); - - /// - /// Gets or sets the input utterance that was analyzed. - /// - [JsonProperty(PropertyName = "query")] - public string Query { get; set; } - - /// - /// Gets or sets the corrected utterance (when spell checking was - /// enabled). - /// - [JsonProperty(PropertyName = "alteredQuery")] - public string AlteredQuery { get; set; } - - /// - /// - [JsonProperty(PropertyName = "topScoringIntent")] - public IntentModel TopScoringIntent { get; set; } - - /// - /// Gets or sets all the intents (and their score) that were detected - /// from utterance. - /// - [JsonProperty(PropertyName = "intents")] - public IList Intents { get; set; } - - /// - /// Gets or sets the entities extracted from the utterance. - /// - [JsonProperty(PropertyName = "entities")] - public IList Entities { get; set; } - - /// - /// Gets or sets the composite entities extracted from the utterance. - /// - [JsonProperty(PropertyName = "compositeEntities")] - public IList CompositeEntities { get; set; } - - /// - /// - [JsonProperty(PropertyName = "sentimentAnalysis")] - public Sentiment SentimentAnalysis { get; set; } - - /// - /// - [JsonProperty(PropertyName = "connectedServiceResult")] - public LuisResult ConnectedServiceResult { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (TopScoringIntent != null) - { - TopScoringIntent.Validate(); - } - if (Intents != null) - { - foreach (var element in Intents) - { - if (element != null) - { - element.Validate(); - } - } - } - if (Entities != null) - { - foreach (var element1 in Entities) - { - if (element1 != null) - { - element1.Validate(); - } - } - } - if (CompositeEntities != null) - { - foreach (var element2 in CompositeEntities) - { - if (element2 != null) - { - element2.Validate(); - } - } - } - if (ConnectedServiceResult != null) - { - ConnectedServiceResult.Validate(); - } - } - } -} diff --git a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/Prediction.cs b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/Prediction.cs new file mode 100644 index 000000000000..bfe8577b86cf --- /dev/null +++ b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/Prediction.cs @@ -0,0 +1,140 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents the prediction of a query. + /// + public partial class Prediction + { + /// + /// Initializes a new instance of the Prediction class. + /// + public Prediction() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Prediction class. + /// + /// The query after pre-processing and + /// normalization. + /// The name of the top scoring intent. + /// A dictionary representing the intents that + /// fired. + /// The dictionary representing the entities + /// that fired. + /// The query after spell checking. Only set + /// if spell check was enabled and a spelling mistake was + /// found. + /// The result of the sentiment + /// analysis. + public Prediction(string normalizedQuery, string topIntent, IDictionary intents, IDictionary entities, string alteredQuery = default(string), Sentiment sentiment = default(Sentiment)) + { + NormalizedQuery = normalizedQuery; + AlteredQuery = alteredQuery; + TopIntent = topIntent; + Intents = intents; + Entities = entities; + Sentiment = sentiment; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the query after pre-processing and normalization. + /// + [JsonProperty(PropertyName = "normalizedQuery")] + public string NormalizedQuery { get; set; } + + /// + /// Gets or sets the query after spell checking. Only set if spell + /// check was enabled and a spelling mistake was found. + /// + [JsonProperty(PropertyName = "alteredQuery")] + public string AlteredQuery { get; set; } + + /// + /// Gets or sets the name of the top scoring intent. + /// + [JsonProperty(PropertyName = "topIntent")] + public string TopIntent { get; set; } + + /// + /// Gets or sets a dictionary representing the intents that fired. + /// + [JsonProperty(PropertyName = "intents")] + public IDictionary Intents { get; set; } + + /// + /// Gets or sets the dictionary representing the entities that fired. + /// + [JsonProperty(PropertyName = "entities")] + public IDictionary Entities { get; set; } + + /// + /// Gets or sets the result of the sentiment analysis. + /// + [JsonProperty(PropertyName = "sentiment")] + public Sentiment Sentiment { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (NormalizedQuery == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "NormalizedQuery"); + } + if (TopIntent == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "TopIntent"); + } + if (Intents == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Intents"); + } + if (Entities == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Entities"); + } + if (Intents != null) + { + foreach (var valueElement in Intents.Values) + { + if (valueElement != null) + { + valueElement.Validate(); + } + } + } + if (Sentiment != null) + { + Sentiment.Validate(); + } + } + } +} diff --git a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/PredictionRequest.cs b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/PredictionRequest.cs new file mode 100644 index 000000000000..369e4bc04717 --- /dev/null +++ b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/PredictionRequest.cs @@ -0,0 +1,114 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents the prediction request parameters. + /// + public partial class PredictionRequest + { + /// + /// Initializes a new instance of the PredictionRequest class. + /// + public PredictionRequest() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PredictionRequest class. + /// + /// The query to predict + /// The custom options defined for this + /// request. + /// The externally predicted entities + /// for this request + /// The dynamically created list entities + /// for this request + public PredictionRequest(string query, PredictionRequestOptions options = default(PredictionRequestOptions), IList externalEntities = default(IList), IList dynamicLists = default(IList)) + { + Query = query; + Options = options; + ExternalEntities = externalEntities; + DynamicLists = dynamicLists; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the query to predict + /// + [JsonProperty(PropertyName = "query")] + public string Query { get; set; } + + /// + /// Gets or sets the custom options defined for this request. + /// + [JsonProperty(PropertyName = "options")] + public PredictionRequestOptions Options { get; set; } + + /// + /// Gets or sets the externally predicted entities for this request + /// + [JsonProperty(PropertyName = "externalEntities")] + public IList ExternalEntities { get; set; } + + /// + /// Gets or sets the dynamically created list entities for this request + /// + [JsonProperty(PropertyName = "dynamicLists")] + public IList DynamicLists { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Query == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Query"); + } + if (ExternalEntities != null) + { + foreach (var element in ExternalEntities) + { + if (element != null) + { + element.Validate(); + } + } + } + if (DynamicLists != null) + { + foreach (var element1 in DynamicLists) + { + if (element1 != null) + { + element1.Validate(); + } + } + } + } + } +} diff --git a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/PredictionRequestOptions.cs b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/PredictionRequestOptions.cs new file mode 100644 index 000000000000..967844d64cfb --- /dev/null +++ b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/PredictionRequestOptions.cs @@ -0,0 +1,64 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The custom options for the prediction request. + /// + public partial class PredictionRequestOptions + { + /// + /// Initializes a new instance of the PredictionRequestOptions class. + /// + public PredictionRequestOptions() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PredictionRequestOptions class. + /// + /// The reference DateTime used for + /// predicting datetime entities. + /// Whether to make the external + /// entities resolution override the predictions if an overlap + /// occurs. + public PredictionRequestOptions(System.DateTime? datetimeReference = default(System.DateTime?), bool? overridePredictions = default(bool?)) + { + DatetimeReference = datetimeReference; + OverridePredictions = overridePredictions; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the reference DateTime used for predicting datetime + /// entities. + /// + [JsonProperty(PropertyName = "datetimeReference")] + public System.DateTime? DatetimeReference { get; set; } + + /// + /// Gets or sets whether to make the external entities resolution + /// override the predictions if an overlap occurs. + /// + [JsonProperty(PropertyName = "overridePredictions")] + public bool? OverridePredictions { get; set; } + + } +} diff --git a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/PredictionResponse.cs b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/PredictionResponse.cs new file mode 100644 index 000000000000..fa44df39b3ed --- /dev/null +++ b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/PredictionResponse.cs @@ -0,0 +1,82 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents the prediction response. + /// + public partial class PredictionResponse + { + /// + /// Initializes a new instance of the PredictionResponse class. + /// + public PredictionResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PredictionResponse class. + /// + /// The query used in the prediction. + /// The prediction of the requested + /// query. + public PredictionResponse(string query, Prediction prediction) + { + Query = query; + Prediction = prediction; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the query used in the prediction. + /// + [JsonProperty(PropertyName = "query")] + public string Query { get; set; } + + /// + /// Gets or sets the prediction of the requested query. + /// + [JsonProperty(PropertyName = "prediction")] + public Prediction Prediction { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Query == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Query"); + } + if (Prediction == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Prediction"); + } + if (Prediction != null) + { + Prediction.Validate(); + } + } + } +} diff --git a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/RequestList.cs b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/RequestList.cs new file mode 100644 index 000000000000..80927882b05a --- /dev/null +++ b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/RequestList.cs @@ -0,0 +1,84 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Defines a sub-list to append to an existing list entity. + /// + public partial class RequestList + { + /// + /// Initializes a new instance of the RequestList class. + /// + public RequestList() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RequestList class. + /// + /// The canonical form of the + /// sub-list. + /// The name of the sub-list. + /// The synonyms of the canonical form. + public RequestList(string canonicalForm, string name = default(string), IList synonyms = default(IList)) + { + Name = name; + CanonicalForm = canonicalForm; + Synonyms = synonyms; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the sub-list. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the canonical form of the sub-list. + /// + [JsonProperty(PropertyName = "canonicalForm")] + public string CanonicalForm { get; set; } + + /// + /// Gets or sets the synonyms of the canonical form. + /// + [JsonProperty(PropertyName = "synonyms")] + public IList Synonyms { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (CanonicalForm == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "CanonicalForm"); + } + } + } +} diff --git a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/Sentiment.cs b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/Sentiment.cs index 52c2fad41efb..b4257ca4a472 100644 --- a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/Sentiment.cs +++ b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Models/Sentiment.cs @@ -14,7 +14,7 @@ namespace Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.Models using System.Linq; /// - /// Sentiment of the input utterance. + /// The result of the sentiment analaysis. /// public partial class Sentiment { @@ -29,14 +29,13 @@ public Sentiment() /// /// Initializes a new instance of the Sentiment class. /// - /// The polarity of the sentiment, can be positive, - /// neutral or negative. - /// Score of the sentiment, ranges from 0 (most - /// negative) to 1 (most positive). - public Sentiment(string label = default(string), double? score = default(double?)) + /// The sentiment score of the query. + /// The label of the sentiment analysis + /// result. + public Sentiment(double score, string label = default(string)) { - Label = label; Score = score; + Label = label; CustomInit(); } @@ -46,18 +45,26 @@ public Sentiment() partial void CustomInit(); /// - /// Gets or sets the polarity of the sentiment, can be positive, - /// neutral or negative. + /// Gets or sets the sentiment score of the query. + /// + [JsonProperty(PropertyName = "score")] + public double Score { get; set; } + + /// + /// Gets or sets the label of the sentiment analysis result. /// [JsonProperty(PropertyName = "label")] public string Label { get; set; } /// - /// Gets or sets score of the sentiment, ranges from 0 (most negative) - /// to 1 (most positive). + /// Validate the object. /// - [JsonProperty(PropertyName = "score")] - public double? Score { get; set; } - + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + //Nothing to validate + } } } diff --git a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Prediction.cs b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Prediction.cs deleted file mode 100644 index 93195fa685bd..000000000000 --- a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/Prediction.cs +++ /dev/null @@ -1,278 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime -{ - using Microsoft.Rest; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Prediction operations. - /// - public partial class Prediction : IServiceOperations, IPrediction - { - /// - /// Initializes a new instance of the Prediction class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - public Prediction(LUISRuntimeClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the LUISRuntimeClient - /// - public LUISRuntimeClient Client { get; private set; } - - /// - /// Gets predictions for a given utterance, in the form of intents and - /// entities. The current maximum query size is 500 characters. - /// - /// - /// The LUIS application ID (Guid). - /// - /// - /// The utterance to predict. - /// - /// - /// The timezone offset for the location of the request. - /// - /// - /// If true, return all intents instead of just the top scoring intent. - /// - /// - /// Use the staging endpoint slot. - /// - /// - /// Enable spell checking. - /// - /// - /// The subscription key to use when enabling Bing spell check - /// - /// - /// Log query (default is true) - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> ResolveWithHttpMessagesAsync(System.Guid appId, string query, double? timezoneOffset = default(double?), bool? verbose = default(bool?), bool? staging = default(bool?), bool? spellCheck = default(bool?), string bingSpellCheckSubscriptionKey = default(string), bool? log = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.Endpoint == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); - } - if (query == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "query"); - } - if (query != null) - { - if (query.Length > 500) - { - throw new ValidationException(ValidationRules.MaxLength, "query", 500); - } - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("appId", appId); - tracingParameters.Add("query", query); - tracingParameters.Add("timezoneOffset", timezoneOffset); - tracingParameters.Add("verbose", verbose); - tracingParameters.Add("staging", staging); - tracingParameters.Add("spellCheck", spellCheck); - tracingParameters.Add("bingSpellCheckSubscriptionKey", bingSpellCheckSubscriptionKey); - tracingParameters.Add("log", log); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Resolve", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri; - var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}"; - _url = _url.Replace("{Endpoint}", Client.Endpoint); - _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(appId, Client.SerializationSettings).Trim('"'))); - List _queryParameters = new List(); - if (timezoneOffset != null) - { - _queryParameters.Add(string.Format("timezoneOffset={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(timezoneOffset, Client.SerializationSettings).Trim('"')))); - } - if (verbose != null) - { - _queryParameters.Add(string.Format("verbose={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(verbose, Client.SerializationSettings).Trim('"')))); - } - if (staging != null) - { - _queryParameters.Add(string.Format("staging={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(staging, Client.SerializationSettings).Trim('"')))); - } - if (spellCheck != null) - { - _queryParameters.Add(string.Format("spellCheck={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(spellCheck, Client.SerializationSettings).Trim('"')))); - } - if (bingSpellCheckSubscriptionKey != null) - { - _queryParameters.Add(string.Format("bing-spell-check-subscription-key={0}", System.Uri.EscapeDataString(bingSpellCheckSubscriptionKey))); - } - if (log != null) - { - _queryParameters.Add(string.Format("log={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(log, Client.SerializationSettings).Trim('"')))); - } - if (_queryParameters.Count > 0) - { - _url += "?" + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - - - if (customHeaders != null) - { - foreach(var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if(query != null) - { - _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(query, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new APIErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - APIError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new HttpOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} diff --git a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/PredictionExtensions.cs b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/PredictionExtensions.cs deleted file mode 100644 index 352df2929603..000000000000 --- a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/PredictionExtensions.cs +++ /dev/null @@ -1,65 +0,0 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. -// - -namespace Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime -{ - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for Prediction. - /// - public static partial class PredictionExtensions - { - /// - /// Gets predictions for a given utterance, in the form of intents and - /// entities. The current maximum query size is 500 characters. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The LUIS application ID (Guid). - /// - /// - /// The utterance to predict. - /// - /// - /// The timezone offset for the location of the request. - /// - /// - /// If true, return all intents instead of just the top scoring intent. - /// - /// - /// Use the staging endpoint slot. - /// - /// - /// Enable spell checking. - /// - /// - /// The subscription key to use when enabling Bing spell check - /// - /// - /// Log query (default is true) - /// - /// - /// The cancellation token. - /// - public static async Task ResolveAsync(this IPrediction operations, System.Guid appId, string query, double? timezoneOffset = default(double?), bool? verbose = default(bool?), bool? staging = default(bool?), bool? spellCheck = default(bool?), string bingSpellCheckSubscriptionKey = default(string), bool? log = default(bool?), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ResolveWithHttpMessagesAsync(appId, query, timezoneOffset, verbose, staging, spellCheck, bingSpellCheckSubscriptionKey, log, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -} diff --git a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/PredictionOperations.cs b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/PredictionOperations.cs new file mode 100644 index 000000000000..63d9f2e3bdf0 --- /dev/null +++ b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/PredictionOperations.cs @@ -0,0 +1,468 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime +{ + using Microsoft.Rest; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PredictionOperations operations. + /// + public partial class PredictionOperations : IServiceOperations, IPredictionOperations + { + /// + /// Initializes a new instance of the PredictionOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + public PredictionOperations(LUISRuntimeClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the LUISRuntimeClient + /// + public LUISRuntimeClient Client { get; private set; } + + /// + /// Gets the predictions for an application version. + /// + /// + /// The application ID. + /// + /// + /// The application version ID. + /// + /// + /// The prediction request parameters. + /// + /// + /// Indicates whether to get extra metadata for the entities predictions or + /// not. + /// + /// + /// Indicates whether to return all the intents in the response or just the top + /// intent. + /// + /// + /// Indicates whether to log the endpoint query or not. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetVersionPredictionWithHttpMessagesAsync(System.Guid appId, string versionId, PredictionRequest predictionRequest, bool? verbose = default(bool?), bool? showAllIntents = default(bool?), bool? log = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.Endpoint == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); + } + if (versionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); + } + if (predictionRequest == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "predictionRequest"); + } + if (predictionRequest != null) + { + predictionRequest.Validate(); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("appId", appId); + tracingParameters.Add("versionId", versionId); + tracingParameters.Add("verbose", verbose); + tracingParameters.Add("showAllIntents", showAllIntents); + tracingParameters.Add("log", log); + tracingParameters.Add("predictionRequest", predictionRequest); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetVersionPrediction", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri; + var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/predict"; + _url = _url.Replace("{Endpoint}", Client.Endpoint); + _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(appId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); + List _queryParameters = new List(); + if (verbose != null) + { + _queryParameters.Add(string.Format("verbose={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(verbose, Client.SerializationSettings).Trim('"')))); + } + if (showAllIntents != null) + { + _queryParameters.Add(string.Format("show-all-intents={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(showAllIntents, Client.SerializationSettings).Trim('"')))); + } + if (log != null) + { + _queryParameters.Add(string.Format("log={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(log, Client.SerializationSettings).Trim('"')))); + } + if (_queryParameters.Count > 0) + { + _url += "?" + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(predictionRequest != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(predictionRequest, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + Error _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets the predictions for an application slot. + /// + /// + /// The application ID. + /// + /// + /// The application slot name. + /// + /// + /// The prediction request parameters. + /// + /// + /// Indicates whether to get extra metadata for the entities predictions or + /// not. + /// + /// + /// Indicates whether to return all the intents in the response or just the top + /// intent. + /// + /// + /// Indicates whether to log the endpoint query or not. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetSlotPredictionWithHttpMessagesAsync(System.Guid appId, string slotName, PredictionRequest predictionRequest, bool? verbose = default(bool?), bool? showAllIntents = default(bool?), bool? log = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.Endpoint == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); + } + if (slotName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "slotName"); + } + if (predictionRequest == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "predictionRequest"); + } + if (predictionRequest != null) + { + predictionRequest.Validate(); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("appId", appId); + tracingParameters.Add("slotName", slotName); + tracingParameters.Add("verbose", verbose); + tracingParameters.Add("showAllIntents", showAllIntents); + tracingParameters.Add("log", log); + tracingParameters.Add("predictionRequest", predictionRequest); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetSlotPrediction", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri; + var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/slots/{slotName}/predict"; + _url = _url.Replace("{Endpoint}", Client.Endpoint); + _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(appId, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{slotName}", System.Uri.EscapeDataString(slotName)); + List _queryParameters = new List(); + if (verbose != null) + { + _queryParameters.Add(string.Format("verbose={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(verbose, Client.SerializationSettings).Trim('"')))); + } + if (showAllIntents != null) + { + _queryParameters.Add(string.Format("show-all-intents={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(showAllIntents, Client.SerializationSettings).Trim('"')))); + } + if (log != null) + { + _queryParameters.Add(string.Format("log={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(log, Client.SerializationSettings).Trim('"')))); + } + if (_queryParameters.Count > 0) + { + _url += "?" + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(predictionRequest != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(predictionRequest, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + Error _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new HttpOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/PredictionOperationsExtensions.cs b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/PredictionOperationsExtensions.cs new file mode 100644 index 000000000000..a35897547422 --- /dev/null +++ b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/PredictionOperationsExtensions.cs @@ -0,0 +1,97 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime +{ + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PredictionOperations. + /// + public static partial class PredictionOperationsExtensions + { + /// + /// Gets the predictions for an application version. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The application ID. + /// + /// + /// The application version ID. + /// + /// + /// The prediction request parameters. + /// + /// + /// Indicates whether to get extra metadata for the entities predictions or + /// not. + /// + /// + /// Indicates whether to return all the intents in the response or just the top + /// intent. + /// + /// + /// Indicates whether to log the endpoint query or not. + /// + /// + /// The cancellation token. + /// + public static async Task GetVersionPredictionAsync(this IPredictionOperations operations, System.Guid appId, string versionId, PredictionRequest predictionRequest, bool? verbose = default(bool?), bool? showAllIntents = default(bool?), bool? log = default(bool?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetVersionPredictionWithHttpMessagesAsync(appId, versionId, predictionRequest, verbose, showAllIntents, log, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the predictions for an application slot. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The application ID. + /// + /// + /// The application slot name. + /// + /// + /// The prediction request parameters. + /// + /// + /// Indicates whether to get extra metadata for the entities predictions or + /// not. + /// + /// + /// Indicates whether to return all the intents in the response or just the top + /// intent. + /// + /// + /// Indicates whether to log the endpoint query or not. + /// + /// + /// The cancellation token. + /// + public static async Task GetSlotPredictionAsync(this IPredictionOperations operations, System.Guid appId, string slotName, PredictionRequest predictionRequest, bool? verbose = default(bool?), bool? showAllIntents = default(bool?), bool? log = default(bool?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetSlotPredictionWithHttpMessagesAsync(appId, slotName, predictionRequest, verbose, showAllIntents, log, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/SdkInfo_LUISRuntimeClient.cs b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/SdkInfo_LUISRuntimeClient.cs index 53b934b8c443..ae4164b4ca6a 100644 --- a/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/SdkInfo_LUISRuntimeClient.cs +++ b/src/SDKs/CognitiveServices/dataPlane/Language/LUIS/Runtime/Generated/SdkInfo_LUISRuntimeClient.cs @@ -19,7 +19,7 @@ public static IEnumerable> ApiInfo_LUISRuntimeClie { return new Tuple[] { - new Tuple("LUISRuntimeClient", "Prediction", "2.0"), + new Tuple("LUISRuntimeClient", "Prediction", "3.0-preview"), }.AsEnumerable(); } }