| | 1 | | // <auto-generated> |
| | 2 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 3 | | // Licensed under the MIT License. See License.txt in the project root for |
| | 4 | | // license information. |
| | 5 | | // |
| | 6 | | // Code generated by Microsoft (R) AutoRest Code Generator. |
| | 7 | | // Changes may cause incorrect behavior and will be lost if the code is |
| | 8 | | // regenerated. |
| | 9 | | // </auto-generated> |
| | 10 | |
|
| | 11 | | namespace Microsoft.Azure.CognitiveServices.Knowledge.QnAMaker.Models |
| | 12 | | { |
| | 13 | | using Microsoft.Rest; |
| | 14 | | using Newtonsoft.Json; |
| | 15 | | using System.Collections; |
| | 16 | | using System.Collections.Generic; |
| | 17 | | using System.Linq; |
| | 18 | |
|
| | 19 | | /// <summary> |
| | 20 | | /// Q-A object. |
| | 21 | | /// </summary> |
| | 22 | | public partial class QnADTO |
| | 23 | | { |
| | 24 | | /// <summary> |
| | 25 | | /// Initializes a new instance of the QnADTO class. |
| | 26 | | /// </summary> |
| 0 | 27 | | public QnADTO() |
| | 28 | | { |
| | 29 | | CustomInit(); |
| 0 | 30 | | } |
| | 31 | |
|
| | 32 | | /// <summary> |
| | 33 | | /// Initializes a new instance of the QnADTO class. |
| | 34 | | /// </summary> |
| | 35 | | /// <param name="answer">Answer text</param> |
| | 36 | | /// <param name="questions">List of questions associated with the |
| | 37 | | /// answer.</param> |
| | 38 | | /// <param name="id">Unique id for the Q-A.</param> |
| | 39 | | /// <param name="source">Source from which Q-A was indexed. eg. |
| | 40 | | /// https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs</param> |
| | 41 | | /// <param name="metadata">List of metadata associated with the |
| | 42 | | /// answer.</param> |
| | 43 | | /// <param name="context">Context of a QnA</param> |
| 0 | 44 | | public QnADTO(string answer, IList<string> questions, int? id = default(int?), string source = default(string), |
| | 45 | | { |
| 0 | 46 | | Id = id; |
| 0 | 47 | | Answer = answer; |
| 0 | 48 | | Source = source; |
| 0 | 49 | | Questions = questions; |
| 0 | 50 | | Metadata = metadata; |
| 0 | 51 | | Context = context; |
| | 52 | | CustomInit(); |
| 0 | 53 | | } |
| | 54 | |
|
| | 55 | | /// <summary> |
| | 56 | | /// An initialization method that performs custom operations like setting defaults |
| | 57 | | /// </summary> |
| | 58 | | partial void CustomInit(); |
| | 59 | |
|
| | 60 | | /// <summary> |
| | 61 | | /// Gets or sets unique id for the Q-A. |
| | 62 | | /// </summary> |
| | 63 | | [JsonProperty(PropertyName = "id")] |
| 0 | 64 | | public int? Id { get; set; } |
| | 65 | |
|
| | 66 | | /// <summary> |
| | 67 | | /// Gets or sets answer text |
| | 68 | | /// </summary> |
| | 69 | | [JsonProperty(PropertyName = "answer")] |
| 0 | 70 | | public string Answer { get; set; } |
| | 71 | |
|
| | 72 | | /// <summary> |
| | 73 | | /// Gets or sets source from which Q-A was indexed. eg. |
| | 74 | | /// https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs |
| | 75 | | /// </summary> |
| | 76 | | [JsonProperty(PropertyName = "source")] |
| 0 | 77 | | public string Source { get; set; } |
| | 78 | |
|
| | 79 | | /// <summary> |
| | 80 | | /// Gets or sets list of questions associated with the answer. |
| | 81 | | /// </summary> |
| | 82 | | [JsonProperty(PropertyName = "questions")] |
| 0 | 83 | | public IList<string> Questions { get; set; } |
| | 84 | |
|
| | 85 | | /// <summary> |
| | 86 | | /// Gets or sets list of metadata associated with the answer. |
| | 87 | | /// </summary> |
| | 88 | | [JsonProperty(PropertyName = "metadata")] |
| 0 | 89 | | public IList<MetadataDTO> Metadata { get; set; } |
| | 90 | |
|
| | 91 | | /// <summary> |
| | 92 | | /// Gets or sets context of a QnA |
| | 93 | | /// </summary> |
| | 94 | | [JsonProperty(PropertyName = "context")] |
| 0 | 95 | | public QnADTOContext Context { get; set; } |
| | 96 | |
|
| | 97 | | /// <summary> |
| | 98 | | /// Validate the object. |
| | 99 | | /// </summary> |
| | 100 | | /// <exception cref="ValidationException"> |
| | 101 | | /// Thrown if validation fails |
| | 102 | | /// </exception> |
| | 103 | | public virtual void Validate() |
| | 104 | | { |
| 0 | 105 | | if (Answer == null) |
| | 106 | | { |
| 0 | 107 | | throw new ValidationException(ValidationRules.CannotBeNull, "Answer"); |
| | 108 | | } |
| 0 | 109 | | if (Questions == null) |
| | 110 | | { |
| 0 | 111 | | throw new ValidationException(ValidationRules.CannotBeNull, "Questions"); |
| | 112 | | } |
| 0 | 113 | | if (Answer != null) |
| | 114 | | { |
| 0 | 115 | | if (Answer.Length > 25000) |
| | 116 | | { |
| 0 | 117 | | throw new ValidationException(ValidationRules.MaxLength, "Answer", 25000); |
| | 118 | | } |
| 0 | 119 | | if (Answer.Length < 1) |
| | 120 | | { |
| 0 | 121 | | throw new ValidationException(ValidationRules.MinLength, "Answer", 1); |
| | 122 | | } |
| | 123 | | } |
| 0 | 124 | | if (Source != null) |
| | 125 | | { |
| 0 | 126 | | if (Source.Length > 300) |
| | 127 | | { |
| 0 | 128 | | throw new ValidationException(ValidationRules.MaxLength, "Source", 300); |
| | 129 | | } |
| | 130 | | } |
| 0 | 131 | | if (Metadata != null) |
| | 132 | | { |
| 0 | 133 | | foreach (var element in Metadata) |
| | 134 | | { |
| 0 | 135 | | if (element != null) |
| | 136 | | { |
| 0 | 137 | | element.Validate(); |
| | 138 | | } |
| | 139 | | } |
| | 140 | | } |
| 0 | 141 | | if (Context != null) |
| | 142 | | { |
| 0 | 143 | | Context.Validate(); |
| | 144 | | } |
| 0 | 145 | | } |
| | 146 | | } |
| | 147 | | } |