| | 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 | | /// A ranked action with its resulting probability. |
| | 19 | | /// </summary> |
| | 20 | | public partial class RankedAction |
| | 21 | | { |
| | 22 | | /// <summary> |
| | 23 | | /// Initializes a new instance of the RankedAction class. |
| | 24 | | /// </summary> |
| 6 | 25 | | public RankedAction() |
| | 26 | | { |
| | 27 | | CustomInit(); |
| 6 | 28 | | } |
| | 29 | |
|
| | 30 | | /// <summary> |
| | 31 | | /// Initializes a new instance of the RankedAction class. |
| | 32 | | /// </summary> |
| | 33 | | /// <param name="id">Id of the action</param> |
| | 34 | | /// <param name="probability">Probability of the action</param> |
| 0 | 35 | | public RankedAction(string id = default(string), double? probability = default(double?)) |
| | 36 | | { |
| 0 | 37 | | Id = id; |
| 0 | 38 | | Probability = probability; |
| | 39 | | CustomInit(); |
| 0 | 40 | | } |
| | 41 | |
|
| | 42 | | /// <summary> |
| | 43 | | /// An initialization method that performs custom operations like setting defaults |
| | 44 | | /// </summary> |
| | 45 | | partial void CustomInit(); |
| | 46 | |
|
| | 47 | | /// <summary> |
| | 48 | | /// Gets id of the action |
| | 49 | | /// </summary> |
| | 50 | | [JsonProperty(PropertyName = "id")] |
| 12 | 51 | | public string Id { get; private set; } |
| | 52 | |
|
| | 53 | | /// <summary> |
| | 54 | | /// Gets probability of the action |
| | 55 | | /// </summary> |
| | 56 | | [JsonProperty(PropertyName = "probability")] |
| 0 | 57 | | public double? Probability { get; private set; } |
| | 58 | |
|
| | 59 | | /// <summary> |
| | 60 | | /// Validate the object. |
| | 61 | | /// </summary> |
| | 62 | | /// <exception cref="ValidationException"> |
| | 63 | | /// Thrown if validation fails |
| | 64 | | /// </exception> |
| | 65 | | public virtual void Validate() |
| | 66 | | { |
| 0 | 67 | | if (Id != null) |
| | 68 | | { |
| 0 | 69 | | if (Id.Length > 256) |
| | 70 | | { |
| 0 | 71 | | throw new ValidationException(ValidationRules.MaxLength, "Id", 256); |
| | 72 | | } |
| | 73 | | } |
| 0 | 74 | | if (Probability > 1) |
| | 75 | | { |
| 0 | 76 | | throw new ValidationException(ValidationRules.InclusiveMaximum, "Probability", 1); |
| | 77 | | } |
| 0 | 78 | | if (Probability < 0) |
| | 79 | | { |
| 0 | 80 | | throw new ValidationException(ValidationRules.InclusiveMinimum, "Probability", 0); |
| | 81 | | } |
| 0 | 82 | | } |
| | 83 | | } |
| | 84 | | } |