| | 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.Collections; |
| | 16 | | using System.Collections.Generic; |
| | 17 | | using System.Linq; |
| | 18 | |
|
| | 19 | | /// <summary> |
| | 20 | | /// Request a set of actions to be ranked by the Personalizer service. |
| | 21 | | /// </summary> |
| | 22 | | public partial class RankRequest |
| | 23 | | { |
| | 24 | | /// <summary> |
| | 25 | | /// Initializes a new instance of the RankRequest class. |
| | 26 | | /// </summary> |
| 0 | 27 | | public RankRequest() |
| | 28 | | { |
| | 29 | | CustomInit(); |
| 0 | 30 | | } |
| | 31 | |
|
| | 32 | | /// <summary> |
| | 33 | | /// Initializes a new instance of the RankRequest class. |
| | 34 | | /// </summary> |
| | 35 | | /// <param name="actions">The set of actions the Personalizer service |
| | 36 | | /// can pick from. |
| | 37 | | /// The set should not contain more than 50 actions. |
| | 38 | | /// The order of the actions does not affect the rank result but the |
| | 39 | | /// order |
| | 40 | | /// should match the sequence your application would have used to |
| | 41 | | /// display them. |
| | 42 | | /// The first item in the array will be used as Baseline item in |
| | 43 | | /// Offline evaluations.</param> |
| | 44 | | /// <param name="contextFeatures">Features of the context used for |
| | 45 | | /// Personalizer as a |
| | 46 | | /// dictionary of dictionaries. This depends on the application, and |
| | 47 | | /// typically includes features about the current user, their |
| | 48 | | /// device, profile information, aggregated data about time and date, |
| | 49 | | /// etc. |
| | 50 | | /// Features should not include personally identifiable information |
| | 51 | | /// (PII), |
| | 52 | | /// unique UserIDs, or precise timestamps.</param> |
| | 53 | | /// <param name="excludedActions">The set of action ids to exclude from |
| | 54 | | /// ranking.</param> |
| | 55 | | /// <param name="eventId">Optionally pass an eventId that uniquely |
| | 56 | | /// identifies this Rank event. |
| | 57 | | /// If null, the service generates a unique eventId. The eventId will |
| | 58 | | /// be used for |
| | 59 | | /// associating this request with its reward, as well as seeding the |
| | 60 | | /// pseudo-random |
| | 61 | | /// generator when making a Personalizer call.</param> |
| | 62 | | /// <param name="deferActivation">Send false if it is certain the |
| | 63 | | /// rewardActionId in rank results will be shown to the user, therefore |
| | 64 | | /// Personalizer will expect a Reward call, otherwise it will assign |
| | 65 | | /// the default |
| | 66 | | /// Reward to the event. Send true if it is possible the user will not |
| | 67 | | /// see the |
| | 68 | | /// action specified in the rank results, because the page is rendering |
| | 69 | | /// later, or the Rank results may be |
| | 70 | | /// overridden by code further downstream.</param> |
| 4 | 71 | | public RankRequest(IList<RankableAction> actions, IList<object> contextFeatures = default(IList<object>), IList< |
| | 72 | | { |
| 4 | 73 | | ContextFeatures = contextFeatures; |
| 4 | 74 | | Actions = actions; |
| 4 | 75 | | ExcludedActions = excludedActions; |
| 4 | 76 | | EventId = eventId; |
| 4 | 77 | | DeferActivation = deferActivation; |
| | 78 | | CustomInit(); |
| 4 | 79 | | } |
| | 80 | |
|
| | 81 | | /// <summary> |
| | 82 | | /// An initialization method that performs custom operations like setting defaults |
| | 83 | | /// </summary> |
| | 84 | | partial void CustomInit(); |
| | 85 | |
|
| | 86 | | /// <summary> |
| | 87 | | /// Gets or sets features of the context used for Personalizer as a |
| | 88 | | /// dictionary of dictionaries. This depends on the application, and |
| | 89 | | /// typically includes features about the current user, their |
| | 90 | | /// device, profile information, aggregated data about time and date, |
| | 91 | | /// etc. |
| | 92 | | /// Features should not include personally identifiable information |
| | 93 | | /// (PII), |
| | 94 | | /// unique UserIDs, or precise timestamps. |
| | 95 | | /// </summary> |
| | 96 | | [JsonProperty(PropertyName = "contextFeatures")] |
| 8 | 97 | | public IList<object> ContextFeatures { get; set; } |
| | 98 | |
|
| | 99 | | /// <summary> |
| | 100 | | /// Gets or sets the set of actions the Personalizer service can pick |
| | 101 | | /// from. |
| | 102 | | /// The set should not contain more than 50 actions. |
| | 103 | | /// The order of the actions does not affect the rank result but the |
| | 104 | | /// order |
| | 105 | | /// should match the sequence your application would have used to |
| | 106 | | /// display them. |
| | 107 | | /// The first item in the array will be used as Baseline item in |
| | 108 | | /// Offline evaluations. |
| | 109 | | /// </summary> |
| | 110 | | [JsonProperty(PropertyName = "actions")] |
| 20 | 111 | | public IList<RankableAction> Actions { get; set; } |
| | 112 | |
|
| | 113 | | /// <summary> |
| | 114 | | /// Gets or sets the set of action ids to exclude from ranking. |
| | 115 | | /// </summary> |
| | 116 | | [JsonProperty(PropertyName = "excludedActions")] |
| 8 | 117 | | public IList<string> ExcludedActions { get; set; } |
| | 118 | |
|
| | 119 | | /// <summary> |
| | 120 | | /// Gets or sets optionally pass an eventId that uniquely identifies |
| | 121 | | /// this Rank event. |
| | 122 | | /// If null, the service generates a unique eventId. The eventId will |
| | 123 | | /// be used for |
| | 124 | | /// associating this request with its reward, as well as seeding the |
| | 125 | | /// pseudo-random |
| | 126 | | /// generator when making a Personalizer call. |
| | 127 | | /// </summary> |
| | 128 | | [JsonProperty(PropertyName = "eventId")] |
| 14 | 129 | | public string EventId { get; set; } |
| | 130 | |
|
| | 131 | | /// <summary> |
| | 132 | | /// Gets or sets send false if it is certain the rewardActionId in rank |
| | 133 | | /// results will be shown to the user, therefore |
| | 134 | | /// Personalizer will expect a Reward call, otherwise it will assign |
| | 135 | | /// the default |
| | 136 | | /// Reward to the event. Send true if it is possible the user will not |
| | 137 | | /// see the |
| | 138 | | /// action specified in the rank results, because the page is rendering |
| | 139 | | /// later, or the Rank results may be |
| | 140 | | /// overridden by code further downstream. |
| | 141 | | /// </summary> |
| | 142 | | [JsonProperty(PropertyName = "deferActivation")] |
| 8 | 143 | | public bool? DeferActivation { get; set; } |
| | 144 | |
|
| | 145 | | /// <summary> |
| | 146 | | /// Validate the object. |
| | 147 | | /// </summary> |
| | 148 | | /// <exception cref="ValidationException"> |
| | 149 | | /// Thrown if validation fails |
| | 150 | | /// </exception> |
| | 151 | | public virtual void Validate() |
| | 152 | | { |
| 4 | 153 | | if (Actions == null) |
| | 154 | | { |
| 0 | 155 | | throw new ValidationException(ValidationRules.CannotBeNull, "Actions"); |
| | 156 | | } |
| 4 | 157 | | if (Actions != null) |
| | 158 | | { |
| 20 | 159 | | foreach (var element in Actions) |
| | 160 | | { |
| 6 | 161 | | if (element != null) |
| | 162 | | { |
| 6 | 163 | | element.Validate(); |
| | 164 | | } |
| | 165 | | } |
| | 166 | | } |
| 4 | 167 | | if (EventId != null) |
| | 168 | | { |
| 2 | 169 | | if (EventId.Length > 256) |
| | 170 | | { |
| 0 | 171 | | throw new ValidationException(ValidationRules.MaxLength, "EventId", 256); |
| | 172 | | } |
| | 173 | | } |
| 4 | 174 | | } |
| | 175 | | } |
| | 176 | | } |