| | 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.Personalizer.Models |
| | 12 | | { |
| | 13 | | using Microsoft.Rest; |
| | 14 | | using Newtonsoft.Json; |
| | 15 | | using System.Linq; |
| | 16 | |
|
| | 17 | | /// <summary> |
| | 18 | | /// The configuration of the service. |
| | 19 | | /// </summary> |
| | 20 | | public partial class ServiceConfiguration |
| | 21 | | { |
| | 22 | | /// <summary> |
| | 23 | | /// Initializes a new instance of the ServiceConfiguration class. |
| | 24 | | /// </summary> |
| 6 | 25 | | public ServiceConfiguration() |
| | 26 | | { |
| | 27 | | CustomInit(); |
| 6 | 28 | | } |
| | 29 | |
|
| | 30 | | /// <summary> |
| | 31 | | /// Initializes a new instance of the ServiceConfiguration class. |
| | 32 | | /// </summary> |
| | 33 | | /// <param name="rewardWaitTime">The time span waited until a request |
| | 34 | | /// is marked with the default reward. |
| | 35 | | /// For example, PT5M (5 mins). For information about the time format, |
| | 36 | | /// see http://en.wikipedia.org/wiki/ISO_8601#Durations</param> |
| | 37 | | /// <param name="defaultReward">The reward given if a reward is not |
| | 38 | | /// received within the specified wait time.</param> |
| | 39 | | /// <param name="rewardAggregation">The function used to process |
| | 40 | | /// rewards, if multiple reward scores are received before |
| | 41 | | /// rewardWaitTime is over.</param> |
| | 42 | | /// <param name="explorationPercentage">The percentage of rank |
| | 43 | | /// responses that will use exploration.</param> |
| | 44 | | /// <param name="modelExportFrequency">Personalizer will start using |
| | 45 | | /// the most updated trained model for online ranks automatically every |
| | 46 | | /// specified time period. |
| | 47 | | /// For example, PT5M (5 mins). For information about the time format, |
| | 48 | | /// see http://en.wikipedia.org/wiki/ISO_8601#Durations</param> |
| | 49 | | /// <param name="logRetentionDays">Number of days historical logs are |
| | 50 | | /// to be maintained. -1 implies the logs will never be |
| | 51 | | /// deleted.</param> |
| | 52 | | /// <param name="logMirrorEnabled">Flag indicates whether log mirroring |
| | 53 | | /// is enabled.</param> |
| | 54 | | /// <param name="logMirrorSasUri">Azure storage account container SAS |
| | 55 | | /// URI for log mirroring.</param> |
| 0 | 56 | | public ServiceConfiguration(System.TimeSpan rewardWaitTime, double defaultReward, string rewardAggregation, doub |
| | 57 | | { |
| 0 | 58 | | RewardWaitTime = rewardWaitTime; |
| 0 | 59 | | DefaultReward = defaultReward; |
| 0 | 60 | | RewardAggregation = rewardAggregation; |
| 0 | 61 | | ExplorationPercentage = explorationPercentage; |
| 0 | 62 | | ModelExportFrequency = modelExportFrequency; |
| 0 | 63 | | LogMirrorEnabled = logMirrorEnabled; |
| 0 | 64 | | LogMirrorSasUri = logMirrorSasUri; |
| 0 | 65 | | LogRetentionDays = logRetentionDays; |
| | 66 | | CustomInit(); |
| 0 | 67 | | } |
| | 68 | |
|
| | 69 | | /// <summary> |
| | 70 | | /// An initialization method that performs custom operations like setting defaults |
| | 71 | | /// </summary> |
| | 72 | | partial void CustomInit(); |
| | 73 | |
|
| | 74 | | /// <summary> |
| | 75 | | /// Gets or sets the time span waited until a request is marked with |
| | 76 | | /// the default reward. |
| | 77 | | /// For example, PT5M (5 mins). For information about the time format, |
| | 78 | | /// see http://en.wikipedia.org/wiki/ISO_8601#Durations |
| | 79 | | /// </summary> |
| | 80 | | [JsonProperty(PropertyName = "rewardWaitTime")] |
| 18 | 81 | | public System.TimeSpan RewardWaitTime { get; set; } |
| | 82 | |
|
| | 83 | | /// <summary> |
| | 84 | | /// Gets or sets the reward given if a reward is not received within |
| | 85 | | /// the specified wait time. |
| | 86 | | /// </summary> |
| | 87 | | [JsonProperty(PropertyName = "defaultReward")] |
| 18 | 88 | | public double DefaultReward { get; set; } |
| | 89 | |
|
| | 90 | | /// <summary> |
| | 91 | | /// Gets or sets the function used to process rewards, if multiple |
| | 92 | | /// reward scores are received before rewardWaitTime is over. |
| | 93 | | /// </summary> |
| | 94 | | [JsonProperty(PropertyName = "rewardAggregation")] |
| 18 | 95 | | public string RewardAggregation { get; set; } |
| | 96 | |
|
| | 97 | | /// <summary> |
| | 98 | | /// Gets or sets the percentage of rank responses that will use |
| | 99 | | /// exploration. |
| | 100 | | /// </summary> |
| | 101 | | [JsonProperty(PropertyName = "explorationPercentage")] |
| 18 | 102 | | public double ExplorationPercentage { get; set; } |
| | 103 | |
|
| | 104 | | /// <summary> |
| | 105 | | /// Gets or sets personalizer will start using the most updated trained |
| | 106 | | /// model for online ranks automatically every specified time period. |
| | 107 | | /// For example, PT5M (5 mins). For information about the time format, |
| | 108 | | /// see http://en.wikipedia.org/wiki/ISO_8601#Durations |
| | 109 | | /// </summary> |
| | 110 | | [JsonProperty(PropertyName = "modelExportFrequency")] |
| 18 | 111 | | public System.TimeSpan ModelExportFrequency { get; set; } |
| | 112 | |
|
| | 113 | | /// <summary> |
| | 114 | | /// Gets or sets flag indicates whether log mirroring is enabled. |
| | 115 | | /// </summary> |
| | 116 | | [JsonProperty(PropertyName = "logMirrorEnabled")] |
| 0 | 117 | | public bool? LogMirrorEnabled { get; set; } |
| | 118 | |
|
| | 119 | | /// <summary> |
| | 120 | | /// Gets or sets azure storage account container SAS URI for log |
| | 121 | | /// mirroring. |
| | 122 | | /// </summary> |
| | 123 | | [JsonProperty(PropertyName = "logMirrorSasUri")] |
| 0 | 124 | | public string LogMirrorSasUri { get; set; } |
| | 125 | |
|
| | 126 | | /// <summary> |
| | 127 | | /// Gets or sets number of days historical logs are to be maintained. |
| | 128 | | /// -1 implies the logs will never be deleted. |
| | 129 | | /// </summary> |
| | 130 | | [JsonProperty(PropertyName = "logRetentionDays")] |
| 12 | 131 | | public int LogRetentionDays { get; set; } |
| | 132 | |
|
| | 133 | | /// <summary> |
| | 134 | | /// Validate the object. |
| | 135 | | /// </summary> |
| | 136 | | /// <exception cref="ValidationException"> |
| | 137 | | /// Thrown if validation fails |
| | 138 | | /// </exception> |
| | 139 | | public virtual void Validate() |
| | 140 | | { |
| 2 | 141 | | if (RewardAggregation == null) |
| | 142 | | { |
| 0 | 143 | | throw new ValidationException(ValidationRules.CannotBeNull, "RewardAggregation"); |
| | 144 | | } |
| 2 | 145 | | if (DefaultReward > 1) |
| | 146 | | { |
| 0 | 147 | | throw new ValidationException(ValidationRules.InclusiveMaximum, "DefaultReward", 1); |
| | 148 | | } |
| 2 | 149 | | if (DefaultReward < -1) |
| | 150 | | { |
| 0 | 151 | | throw new ValidationException(ValidationRules.InclusiveMinimum, "DefaultReward", -1); |
| | 152 | | } |
| 2 | 153 | | if (RewardAggregation != null) |
| | 154 | | { |
| 2 | 155 | | if (RewardAggregation.Length > 256) |
| | 156 | | { |
| 0 | 157 | | throw new ValidationException(ValidationRules.MaxLength, "RewardAggregation", 256); |
| | 158 | | } |
| | 159 | | } |
| 2 | 160 | | if (ExplorationPercentage > 1) |
| | 161 | | { |
| 0 | 162 | | throw new ValidationException(ValidationRules.InclusiveMaximum, "ExplorationPercentage", 1); |
| | 163 | | } |
| 2 | 164 | | if (ExplorationPercentage < 0) |
| | 165 | | { |
| 0 | 166 | | throw new ValidationException(ValidationRules.InclusiveMinimum, "ExplorationPercentage", 0); |
| | 167 | | } |
| 2 | 168 | | if (LogRetentionDays > 2147483647) |
| | 169 | | { |
| 0 | 170 | | throw new ValidationException(ValidationRules.InclusiveMaximum, "LogRetentionDays", 2147483647); |
| | 171 | | } |
| 2 | 172 | | if (LogRetentionDays < -1) |
| | 173 | | { |
| 0 | 174 | | throw new ValidationException(ValidationRules.InclusiveMinimum, "LogRetentionDays", -1); |
| | 175 | | } |
| 2 | 176 | | } |
| | 177 | | } |
| | 178 | | } |