| | 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 | | /// Post body schema for CreateKb operation. |
| | 21 | | /// </summary> |
| | 22 | | public partial class CreateKbDTO |
| | 23 | | { |
| | 24 | | /// <summary> |
| | 25 | | /// Initializes a new instance of the CreateKbDTO class. |
| | 26 | | /// </summary> |
| 0 | 27 | | public CreateKbDTO() |
| | 28 | | { |
| | 29 | | CustomInit(); |
| 0 | 30 | | } |
| | 31 | |
|
| | 32 | | /// <summary> |
| | 33 | | /// Initializes a new instance of the CreateKbDTO class. |
| | 34 | | /// </summary> |
| | 35 | | /// <param name="name">Friendly name for the knowledgebase.</param> |
| | 36 | | /// <param name="qnaList">List of Q-A (QnADTO) to be added to the |
| | 37 | | /// knowledgebase. Q-A Ids are assigned by the service and should be |
| | 38 | | /// omitted.</param> |
| | 39 | | /// <param name="urls">List of URLs to be used for extracting |
| | 40 | | /// Q-A.</param> |
| | 41 | | /// <param name="files">List of files from which to Extract |
| | 42 | | /// Q-A.</param> |
| | 43 | | /// <param name="enableHierarchicalExtraction">Enable hierarchical |
| | 44 | | /// extraction of Q-A from files and urls. Value to be considered False |
| | 45 | | /// if this field is not present.</param> |
| | 46 | | /// <param name="defaultAnswerUsedForExtraction">Text string to be used |
| | 47 | | /// as the answer in any Q-A which has no extracted answer from the |
| | 48 | | /// document but has a hierarchy. Required when |
| | 49 | | /// EnableHierarchicalExtraction field is set to True.</param> |
| | 50 | | /// <param name="language">Language of the knowledgebase.</param> |
| 0 | 51 | | public CreateKbDTO(string name, IList<QnADTO> qnaList = default(IList<QnADTO>), IList<string> urls = default(ILi |
| | 52 | | { |
| 0 | 53 | | Name = name; |
| 0 | 54 | | QnaList = qnaList; |
| 0 | 55 | | Urls = urls; |
| 0 | 56 | | Files = files; |
| 0 | 57 | | EnableHierarchicalExtraction = enableHierarchicalExtraction; |
| 0 | 58 | | DefaultAnswerUsedForExtraction = defaultAnswerUsedForExtraction; |
| 0 | 59 | | Language = language; |
| | 60 | | CustomInit(); |
| 0 | 61 | | } |
| | 62 | |
|
| | 63 | | /// <summary> |
| | 64 | | /// An initialization method that performs custom operations like setting defaults |
| | 65 | | /// </summary> |
| | 66 | | partial void CustomInit(); |
| | 67 | |
|
| | 68 | | /// <summary> |
| | 69 | | /// Gets or sets friendly name for the knowledgebase. |
| | 70 | | /// </summary> |
| | 71 | | [JsonProperty(PropertyName = "name")] |
| 0 | 72 | | public string Name { get; set; } |
| | 73 | |
|
| | 74 | | /// <summary> |
| | 75 | | /// Gets or sets list of Q-A (QnADTO) to be added to the knowledgebase. |
| | 76 | | /// Q-A Ids are assigned by the service and should be omitted. |
| | 77 | | /// </summary> |
| | 78 | | [JsonProperty(PropertyName = "qnaList")] |
| 0 | 79 | | public IList<QnADTO> QnaList { get; set; } |
| | 80 | |
|
| | 81 | | /// <summary> |
| | 82 | | /// Gets or sets list of URLs to be used for extracting Q-A. |
| | 83 | | /// </summary> |
| | 84 | | [JsonProperty(PropertyName = "urls")] |
| 0 | 85 | | public IList<string> Urls { get; set; } |
| | 86 | |
|
| | 87 | | /// <summary> |
| | 88 | | /// Gets or sets list of files from which to Extract Q-A. |
| | 89 | | /// </summary> |
| | 90 | | [JsonProperty(PropertyName = "files")] |
| 0 | 91 | | public IList<FileDTO> Files { get; set; } |
| | 92 | |
|
| | 93 | | /// <summary> |
| | 94 | | /// Gets or sets enable hierarchical extraction of Q-A from files and |
| | 95 | | /// urls. Value to be considered False if this field is not present. |
| | 96 | | /// </summary> |
| | 97 | | [JsonProperty(PropertyName = "enableHierarchicalExtraction")] |
| 0 | 98 | | public bool? EnableHierarchicalExtraction { get; set; } |
| | 99 | |
|
| | 100 | | /// <summary> |
| | 101 | | /// Gets or sets text string to be used as the answer in any Q-A which |
| | 102 | | /// has no extracted answer from the document but has a hierarchy. |
| | 103 | | /// Required when EnableHierarchicalExtraction field is set to True. |
| | 104 | | /// </summary> |
| | 105 | | [JsonProperty(PropertyName = "defaultAnswerUsedForExtraction")] |
| 0 | 106 | | public string DefaultAnswerUsedForExtraction { get; set; } |
| | 107 | |
|
| | 108 | | /// <summary> |
| | 109 | | /// Gets or sets language of the knowledgebase. |
| | 110 | | /// </summary> |
| | 111 | | [JsonProperty(PropertyName = "language")] |
| 0 | 112 | | public string Language { get; set; } |
| | 113 | |
|
| | 114 | | /// <summary> |
| | 115 | | /// Validate the object. |
| | 116 | | /// </summary> |
| | 117 | | /// <exception cref="ValidationException"> |
| | 118 | | /// Thrown if validation fails |
| | 119 | | /// </exception> |
| | 120 | | public virtual void Validate() |
| | 121 | | { |
| 0 | 122 | | if (Name == null) |
| | 123 | | { |
| 0 | 124 | | throw new ValidationException(ValidationRules.CannotBeNull, "Name"); |
| | 125 | | } |
| 0 | 126 | | if (Name != null) |
| | 127 | | { |
| 0 | 128 | | if (Name.Length > 100) |
| | 129 | | { |
| 0 | 130 | | throw new ValidationException(ValidationRules.MaxLength, "Name", 100); |
| | 131 | | } |
| 0 | 132 | | if (Name.Length < 1) |
| | 133 | | { |
| 0 | 134 | | throw new ValidationException(ValidationRules.MinLength, "Name", 1); |
| | 135 | | } |
| | 136 | | } |
| 0 | 137 | | if (QnaList != null) |
| | 138 | | { |
| 0 | 139 | | foreach (var element in QnaList) |
| | 140 | | { |
| 0 | 141 | | if (element != null) |
| | 142 | | { |
| 0 | 143 | | element.Validate(); |
| | 144 | | } |
| | 145 | | } |
| | 146 | | } |
| 0 | 147 | | if (Files != null) |
| | 148 | | { |
| 0 | 149 | | foreach (var element1 in Files) |
| | 150 | | { |
| 0 | 151 | | if (element1 != null) |
| | 152 | | { |
| 0 | 153 | | element1.Validate(); |
| | 154 | | } |
| | 155 | | } |
| | 156 | | } |
| 0 | 157 | | if (DefaultAnswerUsedForExtraction != null) |
| | 158 | | { |
| 0 | 159 | | if (DefaultAnswerUsedForExtraction.Length > 300) |
| | 160 | | { |
| 0 | 161 | | throw new ValidationException(ValidationRules.MaxLength, "DefaultAnswerUsedForExtraction", 300); |
| | 162 | | } |
| 0 | 163 | | if (DefaultAnswerUsedForExtraction.Length < 1) |
| | 164 | | { |
| 0 | 165 | | throw new ValidationException(ValidationRules.MinLength, "DefaultAnswerUsedForExtraction", 1); |
| | 166 | | } |
| | 167 | | } |
| 0 | 168 | | if (Language != null) |
| | 169 | | { |
| 0 | 170 | | if (Language.Length > 100) |
| | 171 | | { |
| 0 | 172 | | throw new ValidationException(ValidationRules.MaxLength, "Language", 100); |
| | 173 | | } |
| 0 | 174 | | if (Language.Length < 1) |
| | 175 | | { |
| 0 | 176 | | throw new ValidationException(ValidationRules.MinLength, "Language", 1); |
| | 177 | | } |
| | 178 | | } |
| 0 | 179 | | } |
| | 180 | | } |
| | 181 | | } |