| | | 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.Search.Models |
| | | 12 | | { |
| | | 13 | | using Microsoft.Rest; |
| | | 14 | | using Newtonsoft.Json; |
| | | 15 | | using System.Linq; |
| | | 16 | | |
| | | 17 | | /// <summary> |
| | | 18 | | /// Defines a mapping between a field in a data source and a target field |
| | | 19 | | /// in an index. |
| | | 20 | | /// <see |
| | | 21 | | /// href="https://docs.microsoft.com/azure/search/search-indexer-field-mappings" |
| | | 22 | | /// /> |
| | | 23 | | /// </summary> |
| | | 24 | | public partial class FieldMapping |
| | | 25 | | { |
| | | 26 | | /// <summary> |
| | | 27 | | /// Initializes a new instance of the FieldMapping class. |
| | | 28 | | /// </summary> |
| | 336 | 29 | | public FieldMapping() |
| | | 30 | | { |
| | | 31 | | CustomInit(); |
| | 336 | 32 | | } |
| | | 33 | | |
| | | 34 | | /// <summary> |
| | | 35 | | /// Initializes a new instance of the FieldMapping class. |
| | | 36 | | /// </summary> |
| | | 37 | | /// <param name="sourceFieldName">The name of the field in the data |
| | | 38 | | /// source.</param> |
| | | 39 | | /// <param name="targetFieldName">The name of the target field in the |
| | | 40 | | /// index. Same as the source field name by default.</param> |
| | | 41 | | /// <param name="mappingFunction">A function to apply to each source |
| | | 42 | | /// field value before indexing.</param> |
| | 260 | 43 | | public FieldMapping(string sourceFieldName, string targetFieldName = default(string), FieldMappingFunction mappi |
| | | 44 | | { |
| | 260 | 45 | | SourceFieldName = sourceFieldName; |
| | 260 | 46 | | TargetFieldName = targetFieldName; |
| | 260 | 47 | | MappingFunction = mappingFunction; |
| | | 48 | | CustomInit(); |
| | 260 | 49 | | } |
| | | 50 | | |
| | | 51 | | /// <summary> |
| | | 52 | | /// An initialization method that performs custom operations like setting defaults |
| | | 53 | | /// </summary> |
| | | 54 | | partial void CustomInit(); |
| | | 55 | | |
| | | 56 | | /// <summary> |
| | | 57 | | /// Gets or sets the name of the field in the data source. |
| | | 58 | | /// </summary> |
| | | 59 | | [JsonProperty(PropertyName = "sourceFieldName")] |
| | 1364 | 60 | | public string SourceFieldName { get; set; } |
| | | 61 | | |
| | | 62 | | /// <summary> |
| | | 63 | | /// Gets or sets the name of the target field in the index. Same as the |
| | | 64 | | /// source field name by default. |
| | | 65 | | /// </summary> |
| | | 66 | | [JsonProperty(PropertyName = "targetFieldName")] |
| | 1032 | 67 | | public string TargetFieldName { get; set; } |
| | | 68 | | |
| | | 69 | | /// <summary> |
| | | 70 | | /// Gets or sets a function to apply to each source field value before |
| | | 71 | | /// indexing. |
| | | 72 | | /// </summary> |
| | | 73 | | [JsonProperty(PropertyName = "mappingFunction")] |
| | 2020 | 74 | | public FieldMappingFunction MappingFunction { get; set; } |
| | | 75 | | |
| | | 76 | | /// <summary> |
| | | 77 | | /// Validate the object. |
| | | 78 | | /// </summary> |
| | | 79 | | /// <exception cref="ValidationException"> |
| | | 80 | | /// Thrown if validation fails |
| | | 81 | | /// </exception> |
| | | 82 | | public virtual void Validate() |
| | | 83 | | { |
| | 332 | 84 | | if (SourceFieldName == null) |
| | | 85 | | { |
| | 0 | 86 | | throw new ValidationException(ValidationRules.CannotBeNull, "SourceFieldName"); |
| | | 87 | | } |
| | 332 | 88 | | if (MappingFunction != null) |
| | | 89 | | { |
| | 328 | 90 | | MappingFunction.Validate(); |
| | | 91 | | } |
| | 332 | 92 | | } |
| | | 93 | | } |
| | | 94 | | } |