wingify-fme-python-sdk 1.70.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. tests/data/__init__.py +13 -0
  2. tests/data/dummy_test_data_reader.py +63 -0
  3. tests/data/user_storage.py +48 -0
  4. tests/e2e/__init__.py +13 -0
  5. tests/e2e/custom_bucketing_test.py +514 -0
  6. tests/e2e/force_users_test.py +368 -0
  7. tests/e2e/get_flag_test.py +195 -0
  8. tests/unit/__init__.py +13 -0
  9. tests/unit/packages/__init__.py +13 -0
  10. tests/unit/packages/decision_maker/__init__.py +13 -0
  11. tests/unit/packages/decision_maker/decision_maker_test.py +83 -0
  12. tests/unit/packages/segmentation_evaluator/__init__.py +13 -0
  13. tests/unit/packages/segmentation_evaluator/segmentation_evaluator_test.py +284 -0
  14. tests/unit/packages/segmentation_evaluator/segmentation_manager_test.py +215 -0
  15. tests/unit/packages/segmentation_evaluator/web_testing_segment_test.py +216 -0
  16. tests/unit/services/__init__.py +0 -0
  17. tests/unit/services/hooks_manager_test.py +80 -0
  18. tests/unit/services/internal_events_sampling_service_test.py +160 -0
  19. tests/unit/settings/__init__.py +13 -0
  20. tests/unit/settings/settings_schema_validation_test.py +67 -0
  21. tests/unit/utils/__init__.py +0 -0
  22. tests/unit/utils/campaign_util_test.py +248 -0
  23. tests/unit/utils/decision_util_force_users_test.py +790 -0
  24. tests/unit/utils/log_message_test.py +65 -0
  25. tests/unit/vwo_wingify_test.py +175 -0
  26. tests/unit/wingify_client_validation_test.py +72 -0
  27. vwo/__init__.py +35 -0
  28. vwo/models/__init__.py +13 -0
  29. vwo/models/batch_event_data.py +19 -0
  30. vwo/models/user/__init__.py +13 -0
  31. vwo/models/user/context_vwo_model.py +21 -0
  32. vwo/models/user/get_flag.py +19 -0
  33. vwo/models/vwo_options_model.py +21 -0
  34. vwo/packages/__init__.py +13 -0
  35. vwo/packages/logger/__init__.py +13 -0
  36. vwo/packages/logger/enums/__init__.py +13 -0
  37. vwo/packages/logger/enums/log_level_enum.py +19 -0
  38. vwo/packages/storage/__init__.py +13 -0
  39. vwo/packages/storage/connector.py +19 -0
  40. vwo/vwo.py +58 -0
  41. vwo/vwo_builder.py +21 -0
  42. vwo/vwo_client.py +22 -0
  43. wingify/__init__.py +36 -0
  44. wingify/api/__init__.py +13 -0
  45. wingify/api/get_flag_api.py +727 -0
  46. wingify/api/set_attribute_api.py +60 -0
  47. wingify/api/track_api.py +99 -0
  48. wingify/constants/Constants.py +94 -0
  49. wingify/constants/__init__.py +13 -0
  50. wingify/constants/sampled_debug_error_template_keys.py +34 -0
  51. wingify/decorators/__init__.py +13 -0
  52. wingify/decorators/storage_decorator.py +92 -0
  53. wingify/enums/__init__.py +13 -0
  54. wingify/enums/api_enum.py +26 -0
  55. wingify/enums/campaign_type_enum.py +22 -0
  56. wingify/enums/debug_category_enum.py +24 -0
  57. wingify/enums/event_enum.py +26 -0
  58. wingify/enums/headers_enum.py +21 -0
  59. wingify/enums/hooks_enum.py +24 -0
  60. wingify/enums/status_enum.py +21 -0
  61. wingify/enums/storage_enum.py +25 -0
  62. wingify/enums/url_enum.py +29 -0
  63. wingify/models/Alias.py +60 -0
  64. wingify/models/AliasSetResponse.py +43 -0
  65. wingify/models/__init__.py +13 -0
  66. wingify/models/batch_event_data.py +68 -0
  67. wingify/models/campaign/__init__.py +13 -0
  68. wingify/models/campaign/campaign_model.py +140 -0
  69. wingify/models/campaign/feature_model.py +95 -0
  70. wingify/models/campaign/holdout_model.py +94 -0
  71. wingify/models/campaign/impact_campaign_model.py +60 -0
  72. wingify/models/campaign/metric_model.py +42 -0
  73. wingify/models/campaign/rule_model.py +42 -0
  74. wingify/models/campaign/variable_model.py +44 -0
  75. wingify/models/campaign/variation_model.py +109 -0
  76. wingify/models/gateway_service_model.py +48 -0
  77. wingify/models/schemas/__init__.py +13 -0
  78. wingify/models/schemas/campaign_group_schema.py +19 -0
  79. wingify/models/schemas/campaign_metric_schema.py +26 -0
  80. wingify/models/schemas/campaign_schema.py +37 -0
  81. wingify/models/schemas/campaign_variation_schema.py +34 -0
  82. wingify/models/schemas/empty_object_schema.py +15 -0
  83. wingify/models/schemas/feature_schema.py +38 -0
  84. wingify/models/schemas/group_schema.py +37 -0
  85. wingify/models/schemas/holdout_schema.py +29 -0
  86. wingify/models/schemas/rule_schema.py +24 -0
  87. wingify/models/schemas/settings_schema.py +47 -0
  88. wingify/models/schemas/variable_schema.py +24 -0
  89. wingify/models/settings/__init__.py +13 -0
  90. wingify/models/settings/internal_event_sampling_settings_model.py +53 -0
  91. wingify/models/settings/settings_model.py +127 -0
  92. wingify/models/storage/__init__.py +13 -0
  93. wingify/models/storage/storage_model.py +84 -0
  94. wingify/models/user/__init__.py +13 -0
  95. wingify/models/user/context_model.py +113 -0
  96. wingify/models/user/context_vwo_model.py +34 -0
  97. wingify/models/user/get_flag.py +47 -0
  98. wingify/models/vwo_options_model.py +21 -0
  99. wingify/models/wingify_options_model.py +129 -0
  100. wingify/packages/__init__.py +13 -0
  101. wingify/packages/decision_maker/__init__.py +13 -0
  102. wingify/packages/decision_maker/decision_maker.py +89 -0
  103. wingify/packages/logger/__init__.py +13 -0
  104. wingify/packages/logger/core/__init__.py +13 -0
  105. wingify/packages/logger/core/log_manager.py +123 -0
  106. wingify/packages/logger/core/log_transport_manager.py +57 -0
  107. wingify/packages/logger/enums/__init__.py +13 -0
  108. wingify/packages/logger/enums/log_level_enum.py +24 -0
  109. wingify/packages/logger/enums/log_level_number_enum.py +21 -0
  110. wingify/packages/logger/log_message_builder.py +70 -0
  111. wingify/packages/logger/logger.py +38 -0
  112. wingify/packages/logger/transports/__init__.py +13 -0
  113. wingify/packages/logger/transports/console_transport.py +43 -0
  114. wingify/packages/network_layer/__init__.py +13 -0
  115. wingify/packages/network_layer/client/__init__.py +13 -0
  116. wingify/packages/network_layer/client/network_client.py +167 -0
  117. wingify/packages/network_layer/handlers/__init__.py +13 -0
  118. wingify/packages/network_layer/handlers/request_handler.py +40 -0
  119. wingify/packages/network_layer/manager/__init__.py +13 -0
  120. wingify/packages/network_layer/manager/network_manager.py +79 -0
  121. wingify/packages/network_layer/models/__init__.py +13 -0
  122. wingify/packages/network_layer/models/global_request_model.py +70 -0
  123. wingify/packages/network_layer/models/request_model.py +133 -0
  124. wingify/packages/network_layer/models/response_model.py +55 -0
  125. wingify/packages/segmentation_evaluator/__init__.py +13 -0
  126. wingify/packages/segmentation_evaluator/core/__init__.py +13 -0
  127. wingify/packages/segmentation_evaluator/core/segmentation_manager.py +140 -0
  128. wingify/packages/segmentation_evaluator/enums/__init__.py +13 -0
  129. wingify/packages/segmentation_evaluator/enums/segment_operand_regex_enum.py +31 -0
  130. wingify/packages/segmentation_evaluator/enums/segment_operand_value_enum.py +29 -0
  131. wingify/packages/segmentation_evaluator/enums/segment_operator_value_enum.py +37 -0
  132. wingify/packages/segmentation_evaluator/evaluators/__init__.py +13 -0
  133. wingify/packages/segmentation_evaluator/evaluators/segment_evaluator.py +237 -0
  134. wingify/packages/segmentation_evaluator/evaluators/segment_operand_evaluator.py +518 -0
  135. wingify/packages/segmentation_evaluator/utils/__init__.py +13 -0
  136. wingify/packages/segmentation_evaluator/utils/segment_util.py +33 -0
  137. wingify/packages/segmentation_evaluator/utils/web_testing_segment_util.py +295 -0
  138. wingify/packages/storage/__init__.py +13 -0
  139. wingify/packages/storage/connector.py +25 -0
  140. wingify/packages/storage/storage.py +39 -0
  141. wingify/resources/__init__.py +13 -0
  142. wingify/resources/debug-messages.json +21 -0
  143. wingify/resources/error-messages.json +62 -0
  144. wingify/resources/info-message.json +47 -0
  145. wingify/resources/trace-messages.json +1 -0
  146. wingify/resources/warn-messages.json +1 -0
  147. wingify/services/__init__.py +13 -0
  148. wingify/services/batch_event_queue.py +140 -0
  149. wingify/services/campaign_decision_service.py +268 -0
  150. wingify/services/hooks_manager.py +65 -0
  151. wingify/services/internal_events_sampling_service.py +62 -0
  152. wingify/services/settings_manager.py +293 -0
  153. wingify/services/storage_service.py +58 -0
  154. wingify/services/url_service.py +51 -0
  155. wingify/utils/__init__.py +13 -0
  156. wingify/utils/aliasing_util.py +108 -0
  157. wingify/utils/brand_context.py +26 -0
  158. wingify/utils/brand_util.py +37 -0
  159. wingify/utils/campaign_util.py +592 -0
  160. wingify/utils/data_type_util.py +125 -0
  161. wingify/utils/debugger_service_util.py +58 -0
  162. wingify/utils/decision_util.py +589 -0
  163. wingify/utils/event_util.py +85 -0
  164. wingify/utils/function_util.py +188 -0
  165. wingify/utils/gateway_service_util.py +179 -0
  166. wingify/utils/holdout_util.py +264 -0
  167. wingify/utils/impression_util.py +151 -0
  168. wingify/utils/internal_events_sampling_util.py +106 -0
  169. wingify/utils/log_message_util.py +95 -0
  170. wingify/utils/meg_util.py +561 -0
  171. wingify/utils/model_utils.py +136 -0
  172. wingify/utils/network_util.py +706 -0
  173. wingify/utils/rule_evaluation_util.py +102 -0
  174. wingify/utils/settings_util.py +39 -0
  175. wingify/utils/usage_stats_util.py +116 -0
  176. wingify/utils/uuid_util.py +81 -0
  177. wingify/vwo_client.py +21 -0
  178. wingify/wingify.py +159 -0
  179. wingify/wingify_builder.py +282 -0
  180. wingify/wingify_client.py +520 -0
  181. wingify_fme_python_sdk-1.70.0.dist-info/METADATA +1415 -0
  182. wingify_fme_python_sdk-1.70.0.dist-info/RECORD +186 -0
  183. wingify_fme_python_sdk-1.70.0.dist-info/WHEEL +5 -0
  184. wingify_fme_python_sdk-1.70.0.dist-info/licenses/LICENSE +202 -0
  185. wingify_fme_python_sdk-1.70.0.dist-info/licenses/NOTICE +18 -0
  186. wingify_fme_python_sdk-1.70.0.dist-info/top_level.txt +3 -0
@@ -0,0 +1,60 @@
1
+ # Copyright 2024 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from typing import Dict
16
+
17
+ class Alias:
18
+ """
19
+ Alias model for setting and getting the alias ID and user ID.
20
+ """
21
+ def __init__(self, alias_data: Dict):
22
+ """
23
+ Initialize the Alias model with the provided data dictionary.
24
+
25
+ :param alias_data: A dictionary containing the alias ID and user ID.
26
+ """
27
+ self.alias = alias_data.get("aliasId", None)
28
+ self.user_id = alias_data.get("userId", None)
29
+
30
+ def get_alias(self) -> str:
31
+ """
32
+ Get the alias ID.
33
+
34
+ :return: The alias ID as a string.
35
+ """
36
+ return self.alias
37
+
38
+ def set_alias(self, alias: str) -> None:
39
+ """
40
+ Set the alias ID.
41
+
42
+ :param alias: The new alias ID as a string.
43
+ """
44
+ self.alias = alias
45
+
46
+ def get_user_id(self) -> str:
47
+ """
48
+ Get the user ID.
49
+
50
+ :return: The user ID as a string.
51
+ """
52
+ return self.user_id
53
+
54
+ def set_user_id(self, user_id: str) -> None:
55
+ """
56
+ Set the user ID.
57
+
58
+ :param user_id: The new user ID as a string.
59
+ """
60
+ self.user_id = user_id
@@ -0,0 +1,43 @@
1
+ # Copyright 2024 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from typing import Dict
16
+
17
+ class AliasSetResponse:
18
+ """
19
+ AliasSetResponse model for setting and getting the alias set response.
20
+ """
21
+ def __init__(self, alias_set_response_data: Dict):
22
+ """
23
+ Initialize the AliasSetResponse model with the provided data dictionary.
24
+
25
+ :param alias_set_response_data: A dictionary containing the alias set response.
26
+ """
27
+ self.is_alias_set = alias_set_response_data.get("isAliasSet", False)
28
+
29
+ def get_is_alias_set(self) -> bool:
30
+ """
31
+ Get the alias set response boolean.
32
+
33
+ :return: The alias set response boolean.
34
+ """
35
+ return self.is_alias_set
36
+
37
+ def set_is_alias_set(self, is_alias_set: bool) -> None:
38
+ """
39
+ Set the alias set response.
40
+
41
+ :param is_alias_set: The new alias set response boolean.
42
+ """
43
+ self.is_alias_set = is_alias_set
@@ -0,0 +1,13 @@
1
+ # Copyright 2024-2026 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
@@ -0,0 +1,68 @@
1
+ # Copyright 2024 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ class BatchEventData:
17
+ def __init__(self, events_per_request: int = 100, request_time_interval: int = 600, flush_callback=None):
18
+ """
19
+ Initialize the BatchEventData model with optional parameters.
20
+
21
+ :param events_per_request: The number of events to send per batch (default is 100).
22
+ :param request_time_interval: The time interval (in seconds) between batch requests (default is 600 seconds).
23
+ """
24
+ self.events_per_request = events_per_request # Default value: 100
25
+ self.request_time_interval = request_time_interval # Default value: 600
26
+ self.flush_callback = flush_callback
27
+
28
+ def get_events_per_request(self) -> int:
29
+ """
30
+ Get the number of events to send per batch.
31
+ """
32
+ return self.events_per_request
33
+
34
+ def set_events_per_request(self, events_per_request: int) -> None:
35
+ """
36
+ Set the number of events to send per batch.
37
+
38
+ :param events_per_request: The number of events to send per batch.
39
+ """
40
+ self.events_per_request = events_per_request
41
+
42
+ def get_request_time_interval(self) -> int:
43
+ """
44
+ Get the time interval (in seconds) between batch requests.
45
+ """
46
+ return self.request_time_interval
47
+
48
+ def set_request_time_interval(self, request_time_interval: int) -> None:
49
+ """
50
+ Set the time interval (in seconds) between batch requests.
51
+
52
+ :param request_time_interval: The time interval between batch requests in seconds.
53
+ """
54
+ self.request_time_interval = request_time_interval
55
+
56
+ def get_flush_callback(self):
57
+ """
58
+ Get the flush callback function.
59
+ """
60
+ return self.flush_callback
61
+
62
+ def set_flush_callback(self, flush_callback: None):
63
+ """
64
+ Set the flush callback function.
65
+
66
+ :param flush_callback: The callback function to be set.
67
+ """
68
+ self.flush_callback = flush_callback
@@ -0,0 +1,13 @@
1
+ # Copyright 2024-2026 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
@@ -0,0 +1,140 @@
1
+ # Copyright 2024-2026 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ from typing import List, Dict, Any, Optional
17
+ from .variation_model import VariationModel
18
+ from .variable_model import VariableModel
19
+ from .metric_model import MetricModel
20
+
21
+
22
+ class CampaignModel:
23
+ def __init__(
24
+ self,
25
+ id: int,
26
+ isForcedVariationEnabled: bool,
27
+ segments: Dict[str, Any],
28
+ variations: List[VariationModel],
29
+ status: str,
30
+ type: str,
31
+ key: str,
32
+ isAlwaysCheckSegment: bool,
33
+ name: str,
34
+ percentTraffic: Optional[int] = None,
35
+ is_user_list_enabled: bool = False,
36
+ metrics: List[Dict[str, Any]] = [],
37
+ variables: List[Dict[str, Any]] = [],
38
+ variation_id: int = None,
39
+ campaign_id: int = None,
40
+ rule_key: str = None,
41
+ weight: float = 0,
42
+ start_range_variation: float = None,
43
+ end_range_variation: float = None,
44
+ salt: str = None,
45
+ ):
46
+ self._id = id
47
+ self._segments = segments
48
+ self._percent_traffic = percentTraffic
49
+ self.is_user_list_enabled = is_user_list_enabled
50
+ self._key = key
51
+ self._type = type
52
+ self._name = name
53
+ self._is_forced_variation_enabled = isForcedVariationEnabled
54
+ self._variations = variations
55
+ self._metrics = metrics
56
+ self._variables = variables
57
+ self._variation_id = variation_id
58
+ self._campaign_id = campaign_id
59
+ self._rule_key = rule_key
60
+ self._status = status
61
+ self._is_always_check_segment = isAlwaysCheckSegment
62
+ self._weight = weight
63
+ self._start_range_variation = start_range_variation
64
+ self._end_range_variation = end_range_variation
65
+ self._salt = salt
66
+
67
+ def get_id(self) -> int:
68
+ return self._id
69
+
70
+ def get_is_forced_variation_enabled(self) -> bool:
71
+ return self._is_forced_variation_enabled
72
+
73
+ def get_segments(self) -> Dict[str, Any]:
74
+ return self._segments
75
+
76
+ def get_variations(self) -> List[VariationModel]:
77
+ return self._variations
78
+
79
+ def get_status(self) -> str:
80
+ return self._status
81
+
82
+ def get_type(self) -> str:
83
+ return self._type
84
+
85
+ def get_key(self) -> str:
86
+ return self._key
87
+
88
+ def get_is_always_check_segment(self) -> bool:
89
+ return self._is_always_check_segment
90
+
91
+ def get_name(self) -> str:
92
+ return self._name
93
+
94
+ def get_percent_traffic(self) -> Optional[int]:
95
+ return self._percent_traffic
96
+
97
+ def get_is_user_list_enabled(self) -> bool:
98
+ return self.is_user_list_enabled
99
+
100
+ def get_metrics(self) -> List[MetricModel]:
101
+ return self._metrics
102
+
103
+ def get_variables(self) -> List[VariableModel]:
104
+ return self._variables
105
+
106
+ def get_variation_id(self) -> int:
107
+ return self._variation_id
108
+
109
+ def get_campaign_id(self) -> int:
110
+ return self._campaign_id
111
+
112
+ def get_rule_key(self) -> str:
113
+ return self._rule_key
114
+
115
+ def set_rule_key(self, rule_key: str) -> None:
116
+ self._rule_key = rule_key
117
+
118
+ def set_variations(self, variations: List[VariationModel]) -> None:
119
+ self._variations = variations
120
+
121
+ def set_weight(self, weight: float) -> None:
122
+ self._weight = weight
123
+
124
+ def get_weight(self) -> float:
125
+ return self._weight
126
+
127
+ def get_start_range_variation(self) -> float:
128
+ return self._start_range_variation
129
+
130
+ def get_end_range_variation(self) -> float:
131
+ return self._end_range_variation
132
+
133
+ def set_start_range_variation(self, start_range_variation: float) -> None:
134
+ self._start_range_variation = start_range_variation
135
+
136
+ def set_end_range_variation(self, end_range_variation: float) -> None:
137
+ self._end_range_variation = end_range_variation
138
+
139
+ def get_salt(self) -> str:
140
+ return self._salt
@@ -0,0 +1,95 @@
1
+ # Copyright 2024-2026 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ from typing import List, Dict, Any
17
+ from .metric_model import MetricModel
18
+ from .rule_model import RuleModel
19
+ from .rule_model import RuleModel
20
+ from .campaign_model import CampaignModel
21
+ from .impact_campaign_model import ImpactCampaignModel
22
+
23
+
24
+ class FeatureModel:
25
+ def __init__(
26
+ self,
27
+ id: int,
28
+ rules: List[RuleModel],
29
+ status: str,
30
+ key: str,
31
+ metrics: List[MetricModel],
32
+ impactCampaign: ImpactCampaignModel,
33
+ type: str,
34
+ name: str,
35
+ rules_linked_campaign: List[CampaignModel] = [],
36
+ is_gateway_service_required: bool = False,
37
+ isDebuggerEnabled: bool = False,
38
+ ):
39
+ self._id = id
40
+ self._rules = rules
41
+ self._status = status
42
+ self._key = key
43
+ self._metrics = metrics
44
+ self._impact_campaign = impactCampaign
45
+ self._type = type
46
+ self._name = name
47
+ self._rules_linked_campaign = rules_linked_campaign
48
+ self._is_gateway_service_required = is_gateway_service_required
49
+ self._is_debugger_enabled = isDebuggerEnabled
50
+
51
+ def get_id(self) -> int:
52
+ return self._id
53
+
54
+ def get_rules(self) -> List[RuleModel]:
55
+ return self._rules
56
+
57
+ def get_status(self) -> str:
58
+ return self._status
59
+
60
+ def get_key(self) -> str:
61
+ return self._key
62
+
63
+ def get_metrics(self) -> List[MetricModel]:
64
+ return self._metrics
65
+
66
+ def get_impact_campaign(self) -> ImpactCampaignModel:
67
+ return self._impact_campaign
68
+
69
+ def get_type(self) -> str:
70
+ return self._type
71
+
72
+ def get_name(self) -> str:
73
+ return self._name
74
+
75
+ def get_rules_linked_campaign(self) -> List[CampaignModel]:
76
+ return self._rules_linked_campaign
77
+
78
+ def get_is_gateway_service_required(self) -> bool:
79
+ return self._is_gateway_service_required
80
+
81
+ def set_rules_linked_campaign(
82
+ self, rules_linked_campaign: List[CampaignModel]
83
+ ) -> None:
84
+ self._rules_linked_campaign = rules_linked_campaign
85
+
86
+ def set_is_gateway_service_required(
87
+ self, is_gateway_service_required: bool
88
+ ) -> None:
89
+ self._is_gateway_service_required = is_gateway_service_required
90
+
91
+ def get_is_debugger_enabled(self) -> bool:
92
+ return self._is_debugger_enabled
93
+
94
+ def set_is_debugger_enabled(self, is_debugger_enabled: bool) -> None:
95
+ self._is_debugger_enabled = is_debugger_enabled
@@ -0,0 +1,94 @@
1
+ # Copyright 2024-2026 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from typing import Any, Dict, List
16
+
17
+ from .metric_model import MetricModel
18
+
19
+
20
+ class HoldoutModel:
21
+ def __init__(self, data: Dict[str, Any]):
22
+ """
23
+ Initialize the HoldoutModel with the provided data dictionary.
24
+
25
+ :param data: A dictionary containing holdout configuration.
26
+ """
27
+ data = data or {}
28
+
29
+ self._id = data.get("id")
30
+ self._segments = data.get("segments") or {}
31
+ self._percent_traffic = data.get("percentTraffic", 0)
32
+ self._is_global = bool(data.get("isGlobal", False))
33
+
34
+ feature_ids = data.get("featureIds", [])
35
+ self._feature_ids = feature_ids if isinstance(feature_ids, list) else []
36
+
37
+ self._name = data.get("name", "")
38
+
39
+ # Gateway service requirement flag
40
+ self._is_gateway_service_required = bool(
41
+ data.get("isGatewayServiceRequired", False)
42
+ )
43
+
44
+ # Metrics list: supports both "m" and "metrics" keys, mirroring the TS model.
45
+ raw_metrics = data.get("m") or data.get("metrics") or []
46
+ if isinstance(raw_metrics, dict):
47
+ metrics_list: List[MetricModel] = []
48
+ else:
49
+ metrics_list = []
50
+ for metric_data in raw_metrics or []:
51
+ if not isinstance(metric_data, dict):
52
+ continue
53
+ # Keep construction consistent with MetricModel usage in model_utils._parse_metric
54
+ metrics_list.append(
55
+ MetricModel(
56
+ id=metric_data.get("id"),
57
+ hasProps=metric_data.get("hasProps", None),
58
+ type=metric_data.get("type"),
59
+ identifier=metric_data.get("identifier"),
60
+ )
61
+ )
62
+
63
+ self._metrics = metrics_list
64
+
65
+ def get_id(self) -> int:
66
+ return self._id
67
+
68
+ def get_segments(self) -> Dict[str, Any]:
69
+ return self._segments or {}
70
+
71
+ def get_percent_traffic(self) -> int:
72
+ return self._percent_traffic
73
+
74
+ def get_is_global(self) -> bool:
75
+ return self._is_global
76
+
77
+ def get_feature_ids(self) -> List[int]:
78
+ return self._feature_ids
79
+
80
+ def get_metrics(self) -> List[MetricModel]:
81
+ return self._metrics
82
+
83
+ def get_is_gateway_service_required(self) -> bool:
84
+ return self._is_gateway_service_required
85
+
86
+ def set_is_gateway_service_required(self, is_gateway_service_required: bool) -> None:
87
+ self._is_gateway_service_required = is_gateway_service_required
88
+
89
+ def get_name(self) -> str:
90
+ return self._name
91
+
92
+ def set_name(self, name: str) -> None:
93
+ self._name = name
94
+
@@ -0,0 +1,60 @@
1
+ # Copyright 2024-2026 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from typing import Dict
16
+
17
+
18
+ class ImpactCampaignModel:
19
+ def __init__(self, data: Dict):
20
+ """
21
+ Initialize the ImpactCampaignModel with the provided data dictionary.
22
+
23
+ :param data: A dictionary containing the campaign ID and type.
24
+ """
25
+ self._campaign_id = data.get("campaignId", None)
26
+ self._type = data.get("type", None)
27
+
28
+ # Getter methods for accessing private attributes
29
+ def get_campaign_id(self) -> int:
30
+ """
31
+ Get the campaign ID.
32
+
33
+ :return: The campaign ID as an integer.
34
+ """
35
+ return self._campaign_id
36
+
37
+ def get_type(self) -> str:
38
+ """
39
+ Get the type of the campaign.
40
+
41
+ :return: The type as a string.
42
+ """
43
+ return self._type
44
+
45
+ # Setter methods for modifying the attributes
46
+ def set_campaign_id(self, value: int):
47
+ """
48
+ Set the campaign ID.
49
+
50
+ :param value: The new campaign ID as an integer.
51
+ """
52
+ self._campaign_id = value
53
+
54
+ def set_type(self, value: str):
55
+ """
56
+ Set the type of the campaign.
57
+
58
+ :param value: The new type as a string.
59
+ """
60
+ self._type = value
@@ -0,0 +1,42 @@
1
+ # Copyright 2024-2026 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ from typing import Optional
17
+
18
+
19
+ class MetricModel:
20
+ def __init__(
21
+ self,
22
+ id: int,
23
+ hasProps: Optional[bool] = False,
24
+ type: str = None,
25
+ identifier: str = None,
26
+ ):
27
+ self._id = id
28
+ self._has_props = hasProps
29
+ self._type = type
30
+ self._identifier = identifier
31
+
32
+ def get_id(self) -> int:
33
+ return self._id
34
+
35
+ def get_has_props(self) -> bool:
36
+ return self._has_props
37
+
38
+ def get_type(self) -> str:
39
+ return self._type
40
+
41
+ def get_identifier(self) -> str:
42
+ return self._identifier
@@ -0,0 +1,42 @@
1
+ # Copyright 2024-2026 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ from typing import Optional
17
+
18
+
19
+ class RuleModel:
20
+ def __init__(
21
+ self,
22
+ type: str,
23
+ ruleKey: Optional[str],
24
+ variationId: Optional[int] = None,
25
+ campaignId: int = None,
26
+ ):
27
+ self._type = type
28
+ self._rule_key = ruleKey
29
+ self._variation_id = variationId
30
+ self._campaign_id = campaignId
31
+
32
+ def get_type(self) -> str:
33
+ return self._type
34
+
35
+ def get_rule_key(self) -> Optional[str]:
36
+ return self._rule_key
37
+
38
+ def get_variation_id(self) -> Optional[int]:
39
+ return self._variation_id
40
+
41
+ def get_campaign_id(self) -> int:
42
+ return self._campaign_id