< Summary

Class:Microsoft.Azure.CognitiveServices.Knowledge.QnAMaker.Models.CreateKbDTO
Assembly:Microsoft.Azure.CognitiveServices.Knowledge.QnAMaker
File(s):C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Knowledge.QnAMaker\src\Generated\Models\CreateKbDTO.cs
Covered lines:0
Uncovered lines:44
Coverable lines:44
Total lines:181
Line coverage:0% (0 of 44)
Covered branches:0
Total branches:32
Branch coverage:0% (0 of 32)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-0%100%
.ctor(...)-0%100%
get_Name()-0%100%
get_QnaList()-0%100%
get_Urls()-0%100%
get_Files()-0%100%
get_EnableHierarchicalExtraction()-0%100%
get_DefaultAnswerUsedForExtraction()-0%100%
get_Language()-0%100%
Validate()-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Knowledge.QnAMaker\src\Generated\Models\CreateKbDTO.cs

#LineLine coverage
 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
 11namespace 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>
 027        public CreateKbDTO()
 28        {
 29            CustomInit();
 030        }
 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>
 051        public CreateKbDTO(string name, IList<QnADTO> qnaList = default(IList<QnADTO>), IList<string> urls = default(ILi
 52        {
 053            Name = name;
 054            QnaList = qnaList;
 055            Urls = urls;
 056            Files = files;
 057            EnableHierarchicalExtraction = enableHierarchicalExtraction;
 058            DefaultAnswerUsedForExtraction = defaultAnswerUsedForExtraction;
 059            Language = language;
 60            CustomInit();
 061        }
 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")]
 072        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")]
 079        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")]
 085        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")]
 091        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")]
 098        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")]
 0106        public string DefaultAnswerUsedForExtraction { get; set; }
 107
 108        /// <summary>
 109        /// Gets or sets language of the knowledgebase.
 110        /// </summary>
 111        [JsonProperty(PropertyName = "language")]
 0112        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        {
 0122            if (Name == null)
 123            {
 0124                throw new ValidationException(ValidationRules.CannotBeNull, "Name");
 125            }
 0126            if (Name != null)
 127            {
 0128                if (Name.Length > 100)
 129                {
 0130                    throw new ValidationException(ValidationRules.MaxLength, "Name", 100);
 131                }
 0132                if (Name.Length < 1)
 133                {
 0134                    throw new ValidationException(ValidationRules.MinLength, "Name", 1);
 135                }
 136            }
 0137            if (QnaList != null)
 138            {
 0139                foreach (var element in QnaList)
 140                {
 0141                    if (element != null)
 142                    {
 0143                        element.Validate();
 144                    }
 145                }
 146            }
 0147            if (Files != null)
 148            {
 0149                foreach (var element1 in Files)
 150                {
 0151                    if (element1 != null)
 152                    {
 0153                        element1.Validate();
 154                    }
 155                }
 156            }
 0157            if (DefaultAnswerUsedForExtraction != null)
 158            {
 0159                if (DefaultAnswerUsedForExtraction.Length > 300)
 160                {
 0161                    throw new ValidationException(ValidationRules.MaxLength, "DefaultAnswerUsedForExtraction", 300);
 162                }
 0163                if (DefaultAnswerUsedForExtraction.Length < 1)
 164                {
 0165                    throw new ValidationException(ValidationRules.MinLength, "DefaultAnswerUsedForExtraction", 1);
 166                }
 167            }
 0168            if (Language != null)
 169            {
 0170                if (Language.Length > 100)
 171                {
 0172                    throw new ValidationException(ValidationRules.MaxLength, "Language", 100);
 173                }
 0174                if (Language.Length < 1)
 175                {
 0176                    throw new ValidationException(ValidationRules.MinLength, "Language", 1);
 177                }
 178            }
 0179        }
 180    }
 181}