|
| 1 | +/* |
| 2 | + * Copyright 2025, Optimizely |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +using System.Collections.Generic; |
| 18 | +using Newtonsoft.Json; |
| 19 | + |
| 20 | +namespace OptimizelySDK.Entity |
| 21 | +{ |
| 22 | + /// <summary> |
| 23 | + /// Class representing CMAB (Contextual Multi-Armed Bandit) configuration for experiments. |
| 24 | + /// </summary> |
| 25 | + public class Cmab |
| 26 | + { |
| 27 | + /// <summary> |
| 28 | + /// List of attribute IDs that are relevant for CMAB decision making. |
| 29 | + /// These attributes will be used to filter user attributes when making CMAB requests. |
| 30 | + /// </summary> |
| 31 | + [JsonProperty("attributeIds")] |
| 32 | + public List<string> AttributeIds { get; set; } |
| 33 | + |
| 34 | + /// <summary> |
| 35 | + /// Traffic allocation value for CMAB experiments. |
| 36 | + /// Determines what portion of traffic should be allocated to CMAB decision making. |
| 37 | + /// </summary> |
| 38 | + [JsonProperty("trafficAllocation")] |
| 39 | + public int? TrafficAllocation { get; set; } |
| 40 | + |
| 41 | + /// <summary> |
| 42 | + /// Initializes a new instance of the Cmab class with specified values. |
| 43 | + /// </summary> |
| 44 | + /// <param name="attributeIds">List of attribute IDs for CMAB</param> |
| 45 | + /// <param name="trafficAllocation">Traffic allocation value</param> |
| 46 | + public Cmab(List<string> attributeIds, int? trafficAllocation = null) |
| 47 | + { |
| 48 | + AttributeIds = attributeIds ?? new List<string>(); |
| 49 | + TrafficAllocation = trafficAllocation; |
| 50 | + } |
| 51 | + |
| 52 | + /// <summary> |
| 53 | + /// Returns a string representation of the CMAB configuration. |
| 54 | + /// </summary> |
| 55 | + /// <returns>String representation</returns> |
| 56 | + public override string ToString() |
| 57 | + { |
| 58 | + var attributeList = AttributeIds ?? new List<string>(); |
| 59 | + return string.Format("Cmab{{AttributeIds=[{0}], TrafficAllocation={1}}}", |
| 60 | + string.Join(", ", attributeList.ToArray()), TrafficAllocation); |
| 61 | + } |
| 62 | + } |
| 63 | +} |
0 commit comments