flipper 0.16.0 → 1.4.0

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 (285) hide show
  1. checksums.yaml +5 -5
  2. data/.codeclimate.yml +1 -0
  3. data/.github/FUNDING.yml +1 -0
  4. data/.github/dependabot.yml +6 -0
  5. data/.github/workflows/ci.yml +110 -0
  6. data/.github/workflows/examples.yml +105 -0
  7. data/.github/workflows/release.yml +54 -0
  8. data/.rspec +1 -0
  9. data/CLAUDE.md +87 -0
  10. data/Changelog.md +2 -215
  11. data/Dockerfile +1 -1
  12. data/Gemfile +28 -20
  13. data/README.md +72 -62
  14. data/Rakefile +13 -3
  15. data/benchmark/enabled_ips.rb +10 -0
  16. data/benchmark/enabled_multiple_actors_ips.rb +20 -0
  17. data/benchmark/enabled_profile.rb +20 -0
  18. data/benchmark/instrumentation_ips.rb +21 -0
  19. data/benchmark/typecast_ips.rb +27 -0
  20. data/docker-compose.yml +37 -34
  21. data/docs/DockerCompose.md +0 -1
  22. data/docs/README.md +1 -0
  23. data/docs/images/banner.jpg +0 -0
  24. data/docs/images/flipper_cloud.png +0 -0
  25. data/examples/api/basic.ru +18 -0
  26. data/examples/api/custom_memoized.ru +36 -0
  27. data/examples/api/memoized.ru +42 -0
  28. data/examples/basic.rb +1 -12
  29. data/examples/cloud/app.ru +12 -0
  30. data/examples/cloud/backoff_policy.rb +13 -0
  31. data/examples/cloud/basic.rb +22 -0
  32. data/examples/cloud/cloud_setup.rb +20 -0
  33. data/examples/cloud/forked.rb +36 -0
  34. data/examples/cloud/import.rb +17 -0
  35. data/examples/cloud/poll_interval/README.md +111 -0
  36. data/examples/cloud/poll_interval/client.rb +108 -0
  37. data/examples/cloud/poll_interval/server.rb +98 -0
  38. data/examples/cloud/threaded.rb +33 -0
  39. data/examples/configuring_default.rb +2 -5
  40. data/examples/dsl.rb +10 -35
  41. data/examples/enabled_for_actor.rb +10 -15
  42. data/examples/expressions.rb +237 -0
  43. data/examples/group.rb +3 -6
  44. data/examples/group_dynamic_lookup.rb +5 -19
  45. data/examples/group_with_members.rb +4 -14
  46. data/examples/importing.rb +1 -1
  47. data/examples/individual_actor.rb +2 -5
  48. data/examples/instrumentation.rb +2 -2
  49. data/examples/instrumentation_last_accessed_at.rb +38 -0
  50. data/examples/memoizing.rb +35 -0
  51. data/examples/mirroring.rb +59 -0
  52. data/examples/percentage_of_actors.rb +6 -16
  53. data/examples/percentage_of_actors_enabled_check.rb +7 -10
  54. data/examples/percentage_of_actors_group.rb +5 -18
  55. data/examples/percentage_of_time.rb +3 -6
  56. data/examples/strict.rb +18 -0
  57. data/exe/flipper +5 -0
  58. data/flipper-cloud.gemspec +19 -0
  59. data/flipper.gemspec +10 -7
  60. data/lib/flipper/actor.rb +10 -3
  61. data/lib/flipper/adapter.rb +50 -8
  62. data/lib/flipper/adapter_builder.rb +44 -0
  63. data/lib/flipper/adapters/actor_limit.rb +54 -0
  64. data/lib/flipper/adapters/cache_base.rb +161 -0
  65. data/lib/flipper/adapters/dual_write.rb +63 -0
  66. data/lib/flipper/adapters/failover.rb +85 -0
  67. data/lib/flipper/adapters/failsafe.rb +72 -0
  68. data/lib/flipper/adapters/http/client.rb +64 -7
  69. data/lib/flipper/adapters/http/error.rb +19 -1
  70. data/lib/flipper/adapters/http.rb +97 -43
  71. data/lib/flipper/adapters/instrumented.rb +47 -26
  72. data/lib/flipper/adapters/memoizable.rb +44 -40
  73. data/lib/flipper/adapters/memory.rb +75 -111
  74. data/lib/flipper/adapters/operation_logger.rb +22 -78
  75. data/lib/flipper/adapters/poll/poller.rb +2 -0
  76. data/lib/flipper/adapters/poll.rb +52 -0
  77. data/lib/flipper/adapters/pstore.rb +27 -17
  78. data/lib/flipper/adapters/read_only.rb +8 -41
  79. data/lib/flipper/adapters/strict.rb +45 -0
  80. data/lib/flipper/adapters/sync/feature_synchronizer.rb +14 -1
  81. data/lib/flipper/adapters/sync/interval_synchronizer.rb +2 -7
  82. data/lib/flipper/adapters/sync/synchronizer.rb +13 -6
  83. data/lib/flipper/adapters/sync.rb +23 -29
  84. data/lib/flipper/adapters/wrapper.rb +54 -0
  85. data/lib/flipper/cli.rb +314 -0
  86. data/lib/flipper/cloud/configuration.rb +271 -0
  87. data/lib/flipper/cloud/dsl.rb +27 -0
  88. data/lib/flipper/cloud/message_verifier.rb +95 -0
  89. data/lib/flipper/cloud/middleware.rb +63 -0
  90. data/lib/flipper/cloud/migrate.rb +71 -0
  91. data/lib/flipper/cloud/routes.rb +14 -0
  92. data/lib/flipper/cloud/telemetry/backoff_policy.rb +96 -0
  93. data/lib/flipper/cloud/telemetry/instrumenter.rb +22 -0
  94. data/lib/flipper/cloud/telemetry/metric.rb +39 -0
  95. data/lib/flipper/cloud/telemetry/metric_storage.rb +30 -0
  96. data/lib/flipper/cloud/telemetry/submitter.rb +100 -0
  97. data/lib/flipper/cloud/telemetry.rb +191 -0
  98. data/lib/flipper/cloud.rb +54 -0
  99. data/lib/flipper/configuration.rb +54 -7
  100. data/lib/flipper/dsl.rb +58 -47
  101. data/lib/flipper/engine.rb +102 -0
  102. data/lib/flipper/errors.rb +3 -21
  103. data/lib/flipper/export.rb +24 -0
  104. data/lib/flipper/exporter.rb +17 -0
  105. data/lib/flipper/exporters/json/export.rb +32 -0
  106. data/lib/flipper/exporters/json/v1.rb +33 -0
  107. data/lib/flipper/expression/builder.rb +73 -0
  108. data/lib/flipper/expression/constant.rb +25 -0
  109. data/lib/flipper/expression.rb +71 -0
  110. data/lib/flipper/expressions/all.rb +9 -0
  111. data/lib/flipper/expressions/any.rb +9 -0
  112. data/lib/flipper/expressions/boolean.rb +9 -0
  113. data/lib/flipper/expressions/comparable.rb +13 -0
  114. data/lib/flipper/expressions/equal.rb +9 -0
  115. data/lib/flipper/expressions/feature_enabled.rb +34 -0
  116. data/lib/flipper/expressions/greater_than.rb +9 -0
  117. data/lib/flipper/expressions/greater_than_or_equal_to.rb +9 -0
  118. data/lib/flipper/expressions/less_than.rb +9 -0
  119. data/lib/flipper/expressions/less_than_or_equal_to.rb +9 -0
  120. data/lib/flipper/expressions/not_equal.rb +9 -0
  121. data/lib/flipper/expressions/now.rb +9 -0
  122. data/lib/flipper/expressions/number.rb +9 -0
  123. data/lib/flipper/expressions/percentage.rb +9 -0
  124. data/lib/flipper/expressions/percentage_of_actors.rb +12 -0
  125. data/lib/flipper/expressions/property.rb +9 -0
  126. data/lib/flipper/expressions/random.rb +9 -0
  127. data/lib/flipper/expressions/string.rb +9 -0
  128. data/lib/flipper/expressions/time.rb +16 -0
  129. data/lib/flipper/feature.rb +95 -28
  130. data/lib/flipper/feature_check_context.rb +10 -6
  131. data/lib/flipper/gate.rb +13 -11
  132. data/lib/flipper/gate_values.rb +5 -18
  133. data/lib/flipper/gates/actor.rb +10 -17
  134. data/lib/flipper/gates/boolean.rb +1 -1
  135. data/lib/flipper/gates/expression.rb +75 -0
  136. data/lib/flipper/gates/group.rb +5 -7
  137. data/lib/flipper/gates/percentage_of_actors.rb +10 -13
  138. data/lib/flipper/gates/percentage_of_time.rb +1 -2
  139. data/lib/flipper/identifier.rb +17 -0
  140. data/lib/flipper/instrumentation/log_subscriber.rb +35 -8
  141. data/lib/flipper/instrumentation/statsd.rb +4 -2
  142. data/lib/flipper/instrumentation/statsd_subscriber.rb +2 -4
  143. data/lib/flipper/instrumentation/subscriber.rb +8 -5
  144. data/lib/flipper/instrumenters/memory.rb +6 -2
  145. data/lib/flipper/metadata.rb +8 -1
  146. data/lib/flipper/middleware/memoizer.rb +46 -27
  147. data/lib/flipper/middleware/setup_env.rb +13 -3
  148. data/lib/flipper/model/active_record.rb +23 -0
  149. data/lib/flipper/poller.rb +157 -0
  150. data/lib/flipper/serializers/gzip.rb +22 -0
  151. data/lib/flipper/serializers/json.rb +17 -0
  152. data/lib/flipper/spec/shared_adapter_specs.rb +122 -56
  153. data/lib/flipper/test/shared_adapter_test.rb +120 -52
  154. data/lib/flipper/test_help.rb +43 -0
  155. data/lib/flipper/typecast.rb +59 -18
  156. data/lib/flipper/types/actor.rb +19 -13
  157. data/lib/flipper/types/group.rb +12 -5
  158. data/lib/flipper/types/percentage.rb +1 -1
  159. data/lib/flipper/version.rb +11 -1
  160. data/lib/flipper.rb +71 -12
  161. data/lib/generators/flipper/setup_generator.rb +68 -0
  162. data/lib/generators/flipper/templates/initializer.rb +45 -0
  163. data/lib/generators/flipper/templates/update/migrations/01_create_flipper_tables.rb.erb +22 -0
  164. data/lib/generators/flipper/templates/update/migrations/02_change_flipper_gates_value_to_text.rb.erb +18 -0
  165. data/lib/generators/flipper/update_generator.rb +35 -0
  166. data/package-lock.json +41 -0
  167. data/package.json +10 -0
  168. data/spec/fixtures/environment.rb +1 -0
  169. data/spec/fixtures/flipper_pstore_1679087600.json +46 -0
  170. data/spec/flipper/actor_spec.rb +10 -2
  171. data/spec/flipper/adapter_builder_spec.rb +72 -0
  172. data/spec/flipper/adapter_spec.rb +52 -6
  173. data/spec/flipper/adapters/actor_limit_spec.rb +75 -0
  174. data/spec/flipper/adapters/dual_write_spec.rb +82 -0
  175. data/spec/flipper/adapters/failover_spec.rb +141 -0
  176. data/spec/flipper/adapters/failsafe_spec.rb +58 -0
  177. data/spec/flipper/adapters/http/client_spec.rb +61 -0
  178. data/spec/flipper/adapters/http_spec.rb +402 -65
  179. data/spec/flipper/adapters/instrumented_spec.rb +31 -13
  180. data/spec/flipper/adapters/memoizable_spec.rb +51 -33
  181. data/spec/flipper/adapters/memory_spec.rb +33 -5
  182. data/spec/flipper/adapters/operation_logger_spec.rb +38 -12
  183. data/spec/flipper/adapters/poll_spec.rb +41 -0
  184. data/spec/flipper/adapters/pstore_spec.rb +0 -2
  185. data/spec/flipper/adapters/read_only_spec.rb +32 -18
  186. data/spec/flipper/adapters/strict_spec.rb +64 -0
  187. data/spec/flipper/adapters/sync/feature_synchronizer_spec.rb +39 -1
  188. data/spec/flipper/adapters/sync/interval_synchronizer_spec.rb +4 -5
  189. data/spec/flipper/adapters/sync/synchronizer_spec.rb +87 -1
  190. data/spec/flipper/adapters/sync_spec.rb +17 -6
  191. data/spec/flipper/cli_spec.rb +217 -0
  192. data/spec/flipper/cloud/configuration_spec.rb +257 -0
  193. data/spec/flipper/cloud/dsl_spec.rb +90 -0
  194. data/spec/flipper/cloud/message_verifier_spec.rb +104 -0
  195. data/spec/flipper/cloud/middleware_spec.rb +307 -0
  196. data/spec/flipper/cloud/migrate_spec.rb +160 -0
  197. data/spec/flipper/cloud/telemetry/backoff_policy_spec.rb +107 -0
  198. data/spec/flipper/cloud/telemetry/metric_spec.rb +87 -0
  199. data/spec/flipper/cloud/telemetry/metric_storage_spec.rb +58 -0
  200. data/spec/flipper/cloud/telemetry/submitter_spec.rb +145 -0
  201. data/spec/flipper/cloud/telemetry_spec.rb +208 -0
  202. data/spec/flipper/cloud_spec.rb +186 -0
  203. data/spec/flipper/configuration_spec.rb +37 -3
  204. data/spec/flipper/dsl_spec.rb +67 -80
  205. data/spec/flipper/engine_spec.rb +374 -0
  206. data/spec/flipper/export_spec.rb +13 -0
  207. data/spec/flipper/exporter_spec.rb +16 -0
  208. data/spec/flipper/exporters/json/export_spec.rb +60 -0
  209. data/spec/flipper/exporters/json/v1_spec.rb +33 -0
  210. data/spec/flipper/expression/builder_spec.rb +248 -0
  211. data/spec/flipper/expression_spec.rb +188 -0
  212. data/spec/flipper/expressions/all_spec.rb +15 -0
  213. data/spec/flipper/expressions/any_spec.rb +15 -0
  214. data/spec/flipper/expressions/boolean_spec.rb +15 -0
  215. data/spec/flipper/expressions/equal_spec.rb +24 -0
  216. data/spec/flipper/expressions/greater_than_or_equal_to_spec.rb +28 -0
  217. data/spec/flipper/expressions/greater_than_spec.rb +28 -0
  218. data/spec/flipper/expressions/less_than_or_equal_to_spec.rb +28 -0
  219. data/spec/flipper/expressions/less_than_spec.rb +32 -0
  220. data/spec/flipper/expressions/not_equal_spec.rb +15 -0
  221. data/spec/flipper/expressions/now_spec.rb +11 -0
  222. data/spec/flipper/expressions/number_spec.rb +21 -0
  223. data/spec/flipper/expressions/percentage_of_actors_spec.rb +20 -0
  224. data/spec/flipper/expressions/percentage_spec.rb +15 -0
  225. data/spec/flipper/expressions/property_spec.rb +13 -0
  226. data/spec/flipper/expressions/random_spec.rb +9 -0
  227. data/spec/flipper/expressions/string_spec.rb +11 -0
  228. data/spec/flipper/expressions/time_spec.rb +29 -0
  229. data/spec/flipper/feature_check_context_spec.rb +18 -20
  230. data/spec/flipper/feature_spec.rb +461 -48
  231. data/spec/flipper/gate_spec.rb +0 -2
  232. data/spec/flipper/gate_values_spec.rb +2 -34
  233. data/spec/flipper/gates/actor_spec.rb +0 -2
  234. data/spec/flipper/gates/boolean_spec.rb +1 -3
  235. data/spec/flipper/gates/expression_spec.rb +190 -0
  236. data/spec/flipper/gates/group_spec.rb +2 -5
  237. data/spec/flipper/gates/percentage_of_actors_spec.rb +61 -7
  238. data/spec/flipper/gates/percentage_of_time_spec.rb +2 -4
  239. data/spec/flipper/identifier_spec.rb +12 -0
  240. data/spec/flipper/instrumentation/log_subscriber_spec.rb +24 -7
  241. data/spec/flipper/instrumentation/statsd_subscriber_spec.rb +26 -3
  242. data/spec/flipper/instrumenters/memory_spec.rb +18 -1
  243. data/spec/flipper/instrumenters/noop_spec.rb +14 -8
  244. data/spec/flipper/middleware/memoizer_spec.rb +199 -62
  245. data/spec/flipper/middleware/setup_env_spec.rb +23 -5
  246. data/spec/flipper/model/active_record_spec.rb +72 -0
  247. data/spec/flipper/poller_spec.rb +390 -0
  248. data/spec/flipper/registry_spec.rb +0 -1
  249. data/spec/flipper/serializers/gzip_spec.rb +13 -0
  250. data/spec/flipper/serializers/json_spec.rb +13 -0
  251. data/spec/flipper/typecast_spec.rb +121 -7
  252. data/spec/flipper/types/actor_spec.rb +63 -47
  253. data/spec/flipper/types/boolean_spec.rb +0 -1
  254. data/spec/flipper/types/group_spec.rb +24 -3
  255. data/spec/flipper/types/percentage_of_actors_spec.rb +0 -1
  256. data/spec/flipper/types/percentage_of_time_spec.rb +0 -1
  257. data/spec/flipper/types/percentage_spec.rb +0 -1
  258. data/spec/{integration_spec.rb → flipper_integration_spec.rb} +301 -59
  259. data/spec/flipper_spec.rb +123 -29
  260. data/spec/{helper.rb → spec_helper.rb} +23 -21
  261. data/spec/support/actor_names.yml +1 -0
  262. data/spec/support/descriptions.yml +1 -0
  263. data/spec/support/fail_on_output.rb +8 -0
  264. data/spec/support/fake_backoff_policy.rb +15 -0
  265. data/spec/support/skippable.rb +18 -0
  266. data/spec/support/spec_helpers.rb +53 -6
  267. data/test/adapters/actor_limit_test.rb +20 -0
  268. data/test/test_helper.rb +2 -1
  269. data/test_rails/generators/flipper/setup_generator_test.rb +69 -0
  270. data/test_rails/generators/flipper/update_generator_test.rb +96 -0
  271. data/test_rails/helper.rb +31 -0
  272. data/test_rails/system/test_help_test.rb +52 -0
  273. metadata +200 -82
  274. data/.rubocop.yml +0 -54
  275. data/.rubocop_todo.yml +0 -199
  276. data/docs/Adapters.md +0 -124
  277. data/docs/Caveats.md +0 -4
  278. data/docs/Gates.md +0 -167
  279. data/docs/Instrumentation.md +0 -27
  280. data/docs/Optimization.md +0 -114
  281. data/docs/api/README.md +0 -849
  282. data/docs/http/README.md +0 -35
  283. data/docs/read-only/README.md +0 -21
  284. data/examples/example_setup.rb +0 -8
  285. data/test/helper.rb +0 -11
data/docs/api/README.md DELETED
@@ -1,849 +0,0 @@
1
- # Flipper::Api
2
-
3
- API for the [Flipper](https://github.com/jnunemaker/flipper) gem.
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- gem 'flipper-api'
10
-
11
- And then execute:
12
-
13
- $ bundle
14
-
15
- Or install it yourself as:
16
-
17
- $ gem install flipper-api
18
-
19
- ## Usage
20
-
21
- `Flipper::Api` is a mountable application that can be included in your Rails/Ruby apps. In a Rails application, you can mount `Flipper::Api` to a route of your choice:
22
-
23
- ```ruby
24
- # config/routes.rb
25
- YourRailsApp::Application.routes.draw do
26
- mount Flipper::Api.app(flipper) => '/flipper/api'
27
- end
28
- ```
29
-
30
- ### Mount Priority - important if using Flipper::UI
31
-
32
- There can be more than one router in your application. Make sure if you choose a path that begins with the same pattern as where Flipper::UI is mounted that the app with the longer pattern is mounted first.
33
-
34
- *bad:*
35
- ```ruby
36
- YourRailsApp::Application.routes.draw do
37
- mount Flipper::UI.app(flipper) => '/flipper'
38
- mount Flipper::Api.app(flipper) => '/flipper/api'
39
- end
40
- ```
41
-
42
- In this case any requests to /flipper\* will be routed to Flipper::UI - including /flipper/api* requests. Simply swap these two to make sure that any requests that don't match /flipper/api\* will be routed to Flipper::UI.
43
-
44
- *good:*
45
- ```ruby
46
- YourRailsApp::Application.routes.draw do
47
- mount Flipper::Api.app(flipper) => '/flipper/api'
48
- mount Flipper::UI.app(flipper) => '/flipper'
49
- end
50
- ````
51
- For more advanced mounting techniques and for suggestions on how to mount in a non-Rails application, it is recommend that you review the [`Flipper::UI` usage documentation](https://github.com/jnunemaker/flipper/blob/master/docs/ui/README.md#usage) as the same approaches apply to `Flipper::Api`.
52
-
53
- ## Endpoints
54
-
55
- **Note:** Example CURL requests below assume a mount point of `/flipper/api`.
56
-
57
- ### Get all features
58
-
59
- **URL**
60
-
61
- `GET /features`
62
-
63
- **Request**
64
-
65
- ```
66
- curl http://example.com/flipper/api/features
67
- ```
68
-
69
- **Response**
70
-
71
- Returns an array of feature objects:
72
-
73
- ```json
74
- {
75
- "features": [
76
- {
77
- "key": "search",
78
- "state": "on",
79
- "gates": [
80
- {
81
- "key": "boolean",
82
- "name": "boolean",
83
- "value": false
84
- },
85
- {
86
- "key": "groups",
87
- "name": "group",
88
- "value": []
89
- },
90
- {
91
- "key": "actors",
92
- "name": "actor",
93
- "value": []
94
- },
95
- {
96
- "key": "percentage_of_actors",
97
- "name": "percentage_of_actors",
98
- "value": 0
99
- },
100
- {
101
- "key": "percentage_of_time",
102
- "name": "percentage_of_time",
103
- "value": 0
104
- }
105
- ]
106
- },
107
- {
108
- "key": "history",
109
- "state": "off",
110
- "gates": [
111
- {
112
- "key": "boolean",
113
- "name": "boolean",
114
- "value": false
115
- },
116
- {
117
- "key": "groups",
118
- "name": "group",
119
- "value": []
120
- },
121
- {
122
- "key": "actors",
123
- "name": "actor",
124
- "value": []
125
- },
126
- {
127
- "key": "percentage_of_actors",
128
- "name": "percentage_of_actors",
129
- "value": 0
130
- },
131
- {
132
- "key": "percentage_of_time",
133
- "name": "percentage_of_time",
134
- "value": 0
135
- }
136
- ]
137
- }
138
- ]
139
- }
140
- ```
141
-
142
- ### Create a new feature
143
-
144
- **URL**
145
-
146
- `POST /features`
147
-
148
- **Parameters**
149
-
150
- * `name` - The name of the feature (Recommended naming conventions: lower case, snake case, underscores over dashes. Good: foo_bar, foo. Bad: FooBar, Foo Bar, foo bar, foo-bar.)
151
-
152
- **Request**
153
-
154
- ```
155
- curl -X POST -d "name=reports" http://example.com/flipper/api/features
156
- ```
157
-
158
- **Response**
159
-
160
- On successful creation, the API will respond with an empty JSON response.
161
-
162
- ### Retrieve a feature
163
-
164
- **URL**
165
-
166
- `GET /features/{feature_name}`
167
-
168
- **Parameters**
169
-
170
- * `feature_name` - The name of the feature to retrieve
171
-
172
- **Request**
173
-
174
- ```
175
- curl http://example.com/flipper/api/features/reports
176
- ```
177
-
178
- **Response**
179
-
180
- Returns an individual feature object:
181
-
182
- ```json
183
- {
184
- "key": "search",
185
- "state": "off",
186
- "gates": [
187
- {
188
- "key": "boolean",
189
- "name": "boolean",
190
- "value": false
191
- },
192
- {
193
- "key": "groups",
194
- "name": "group",
195
- "value": []
196
- },
197
- {
198
- "key": "actors",
199
- "name": "actor",
200
- "value": []
201
- },
202
- {
203
- "key": "percentage_of_actors",
204
- "name": "percentage_of_actors",
205
- "value": 0
206
- },
207
- {
208
- "key": "percentage_of_time",
209
- "name": "percentage_of_time",
210
- "value": 0
211
- }
212
- ]
213
- }
214
- ```
215
-
216
- ### Delete a feature
217
-
218
- **URL**
219
-
220
- `DELETE /features/{feature_name}`
221
-
222
- **Parameters**
223
-
224
- * `feature_name` - The name of the feature to delete
225
-
226
- **Request**
227
-
228
- ```
229
- curl -X DELETE http://example.com/flipper/api/features/reports
230
- ```
231
-
232
- **Response**
233
-
234
- Successful deletion of a feature will return a 204 No Content response.
235
-
236
- ### Clear a feature
237
-
238
- **URL**
239
-
240
- `DELETE /features/{feature_name}/clear`
241
-
242
- **Parameters**
243
-
244
- * `feature_name` - The name of the feature to clear
245
-
246
- **Request**
247
-
248
- ```
249
- curl -X DELETE http://example.com/flipper/api/features/reports/clear
250
- ```
251
-
252
- **Response**
253
-
254
- Successful clearing (removing of all gate values) of a feature will return a 204 No Content response.
255
-
256
- ## Gates
257
-
258
- The API supports enabling / disabling any of the Flipper [gates](https://github.com/jnunemaker/flipper/blob/master/docs/Gates.md). Gate endpoints follow the url convention:
259
-
260
- **enable**
261
-
262
- `POST /{feature_name}/{gate_name}`
263
-
264
- **disable**
265
-
266
- `DELETE /{feature_name}/{gate_name}`
267
-
268
- and on a succesful request return a 200 HTTP status and the feature object as the response body.
269
-
270
- ### Boolean enable a feature
271
-
272
- **URL**
273
-
274
- `POST /features/{feature_name}/boolean`
275
-
276
- **Parameters**
277
-
278
- * `feature_name` - The name of the feature to enable
279
-
280
- **Request**
281
-
282
- ```
283
- curl -X POST http://example.com/flipper/api/features/reports/boolean
284
- ```
285
-
286
- **Response**
287
-
288
- Successful enabling of the boolean gate will return a 200 HTTP status and the feature object as the response body.
289
-
290
- ```json
291
- {
292
- "key": "reports",
293
- "state": "on",
294
- "gates": [
295
- {
296
- "key": "boolean",
297
- "name": "boolean",
298
- "value": true
299
- },
300
- {
301
- "key": "groups",
302
- "name": "group",
303
- "value": []
304
- },
305
- {
306
- "key": "actors",
307
- "name": "actor",
308
- "value": []
309
- },
310
- {
311
- "key": "percentage_of_actors",
312
- "name": "percentage_of_actors",
313
- "value": 0
314
- },
315
- {
316
- "key": "percentage_of_time",
317
- "name": "percentage_of_time",
318
- "value": 0
319
- }
320
- ]
321
- }
322
- ```
323
-
324
-
325
- ### Boolean disable a feature
326
-
327
- **URL**
328
-
329
- `DELETE /features/{feature_name}/boolean`
330
-
331
- **Parameters**
332
-
333
- * `feature_name` - The name of the feature to disable
334
-
335
- **Request**
336
-
337
- ```
338
- curl -X DELETE http://example.com/flipper/api/features/reports/boolean
339
- ```
340
-
341
- **Response**
342
-
343
- Successful disabling of the boolean gate will return a 200 HTTP status and the feature object.
344
-
345
- ```json
346
- {
347
- "key": "reports",
348
- "state": "off",
349
- "gates": [
350
- {
351
- "key": "boolean",
352
- "name": "boolean",
353
- "value": false
354
- },
355
- {
356
- "key": "groups",
357
- "name": "group",
358
- "value": []
359
- },
360
- {
361
- "key": "actors",
362
- "name": "actor",
363
- "value": []
364
- },
365
- {
366
- "key": "percentage_of_actors",
367
- "name": "percentage_of_actors",
368
- "value": 0
369
- },
370
- {
371
- "key": "percentage_of_time",
372
- "name": "percentage_of_time",
373
- "value": 0
374
- }
375
- ]
376
- }
377
- ```
378
-
379
- ### Enable Group
380
-
381
- **URL**
382
-
383
- `POST /features/{feature_name}/groups`
384
-
385
- **Parameters**
386
-
387
- * `feature_name` - The name of the feature
388
-
389
- * `name` - The name of a registered group to enable
390
-
391
- **Request**
392
-
393
- ```
394
- curl -X POST -d "name=admins" http://example.com/flipper/api/features/reports/groups
395
- ```
396
-
397
- **Response**
398
-
399
- Successful enabling of the group will return a 200 HTTP status and the feature object as the response body.
400
-
401
- ```json
402
- {
403
- "key": "reports",
404
- "state": "conditional",
405
- "gates": [
406
- {
407
- "key": "boolean",
408
- "name": "boolean",
409
- "value": false
410
- },
411
- {
412
- "key": "groups",
413
- "name": "group",
414
- "value": ["admins"]
415
- },
416
- {
417
- "key": "actors",
418
- "name": "actor",
419
- "value": []
420
- },
421
- {
422
- "key": "percentage_of_actors",
423
- "name": "percentage_of_actors",
424
- "value": 0
425
- },
426
- {
427
- "key": "percentage_of_time",
428
- "name": "percentage_of_time",
429
- "value": 0
430
- }
431
- ]
432
- }
433
- ```
434
-
435
- ### Disable Group
436
-
437
- **URL**
438
-
439
- `DELETE /features/{feature_name}/groups`
440
-
441
- **Parameters**
442
-
443
- * `feature_name` - The name of the feature
444
-
445
- * `name` - The name of a registered group to disable
446
-
447
- **Request**
448
-
449
- ```
450
- curl -X DELETE -d "name=admins" http://example.com/flipper/api/features/reports/groups
451
- ```
452
-
453
- **Response**
454
-
455
- Successful disabling of the group will return a 200 HTTP status and the feature object as the response body.
456
-
457
- ```json
458
- {
459
- "key": "reports",
460
- "state": "off",
461
- "gates": [
462
- {
463
- "key": "boolean",
464
- "name": "boolean",
465
- "value": false
466
- },
467
- {
468
- "key": "groups",
469
- "name": "group",
470
- "value": []
471
- },
472
- {
473
- "key": "actors",
474
- "name": "actor",
475
- "value": []
476
- },
477
- {
478
- "key": "percentage_of_actors",
479
- "name": "percentage_of_actors",
480
- "value": 0
481
- },
482
- {
483
- "key": "percentage_of_time",
484
- "name": "percentage_of_time",
485
- "value": 0
486
- }
487
- ]
488
- }
489
- ```
490
- ### Enable Actor
491
-
492
- **URL**
493
-
494
- `POST /features/{feature_name}/actors`
495
-
496
- **Parameters**
497
-
498
- * `feature_name` - The name of the feature
499
-
500
- * `flipper_id` - The flipper_id of actor to enable
501
-
502
- **Request**
503
-
504
- ```
505
- curl -X POST -d "flipper_id=User;1" http://example.com/flipper/api/features/reports/actors
506
- ```
507
-
508
- **Response**
509
-
510
- Successful enabling of the actor will return a 200 HTTP status and the feature object as the response body.
511
-
512
- ```json
513
- {
514
- "key": "reports",
515
- "state": "conditional",
516
- "gates": [
517
- {
518
- "key": "boolean",
519
- "name": "boolean",
520
- "value": false
521
- },
522
- {
523
- "key": "groups",
524
- "name": "group",
525
- "value": []
526
- },
527
- {
528
- "key": "actors",
529
- "name": "actor",
530
- "value": ["User:1"]
531
- },
532
- {
533
- "key": "percentage_of_actors",
534
- "name": "percentage_of_actors",
535
- "value": 0
536
- },
537
- {
538
- "key": "percentage_of_time",
539
- "name": "percentage_of_time",
540
- "value": 0
541
- }
542
- ]
543
- }
544
- ```
545
- ### Disable Actor
546
-
547
- **URL**
548
-
549
- `DELETE /features/{feature_name}/actors`
550
-
551
- **Parameters**
552
-
553
- * `feature_name` - The name of the feature
554
-
555
- * `flipper_id` - The flipper_id of actor to disable
556
-
557
- **Request**
558
-
559
- ```
560
- curl -X DELETE -d "flipper_id=User;1" http://example.com/flipper/api/features/reports/actors
561
- ```
562
-
563
- **Response**
564
-
565
- Successful disabling of the actor will return a 200 HTTP status and the feature object as the response body.
566
-
567
- ```json
568
- {
569
- "key": "reports",
570
- "state": "off",
571
- "gates": [
572
- {
573
- "key": "boolean",
574
- "name": "boolean",
575
- "value": false
576
- },
577
- {
578
- "key": "groups",
579
- "name": "group",
580
- "value": []
581
- },
582
- {
583
- "key": "actors",
584
- "name": "actor",
585
- "value": []
586
- },
587
- {
588
- "key": "percentage_of_actors",
589
- "name": "percentage_of_actors",
590
- "value": 0
591
- },
592
- {
593
- "key": "percentage_of_time",
594
- "name": "percentage_of_time",
595
- "value": 0
596
- }
597
- ]
598
- }
599
- ```
600
-
601
- ### Enable Percentage of Actors
602
-
603
- **URL**
604
-
605
- `POST /features/{feature_name}/percentage_of_actors`
606
-
607
- **Parameters**
608
-
609
- * `feature_name` - The name of the feature
610
-
611
- * `percentage` - The percentage of actors to enable
612
-
613
- **Request**
614
-
615
- ```
616
- curl -X POST -d "percentage=20" http://example.com/flipper/api/features/reports/percentage_of_actors
617
- ```
618
-
619
- **Response**
620
-
621
- Successful enabling of a percentage of actors will return a 200 HTTP status and the feature object as the response body.
622
-
623
- ```json
624
- {
625
- "key": "reports",
626
- "state": "conditional",
627
- "gates": [
628
- {
629
- "key": "boolean",
630
- "name": "boolean",
631
- "value": false
632
- },
633
- {
634
- "key": "groups",
635
- "name": "group",
636
- "value": []
637
- },
638
- {
639
- "key": "actors",
640
- "name": "actor",
641
- "value": []
642
- },
643
- {
644
- "key": "percentage_of_actors",
645
- "name": "percentage_of_actors",
646
- "value": 20
647
- },
648
- {
649
- "key": "percentage_of_time",
650
- "name": "percentage_of_time",
651
- "value": 0
652
- }
653
- ]
654
- }
655
- ```
656
- ### Disable Percentage of Actors
657
-
658
- **URL**
659
-
660
- `DELETE /features/{feature_name}/percentage_of_actors`
661
-
662
- **Parameters**
663
-
664
- * `feature_name` - The name of the feature
665
-
666
- **Request**
667
-
668
- ```
669
- curl -X DELETE http://example.com/flipper/api/features/reports/percentage_of_actors
670
- ```
671
-
672
- **Response**
673
-
674
- Successful disabling of a percentage of actors will set the percentage to 0 and return a 200 HTTP status and the feature object as the response body.
675
-
676
- ```json
677
- {
678
- "key": "reports",
679
- "state": "off",
680
- "gates": [
681
- {
682
- "key": "boolean",
683
- "name": "boolean",
684
- "value": false
685
- },
686
- {
687
- "key": "groups",
688
- "name": "group",
689
- "value": []
690
- },
691
- {
692
- "key": "actors",
693
- "name": "actor",
694
- "value": []
695
- },
696
- {
697
- "key": "percentage_of_actors",
698
- "name": "percentage_of_actors",
699
- "value": 0
700
- },
701
- {
702
- "key": "percentage_of_time",
703
- "name": "percentage_of_time",
704
- "value": 0
705
- }
706
- ]
707
- }
708
- ```
709
- ### Enable Percentage of Time
710
-
711
- **URL**
712
-
713
- `POST /features/{feature_name}/percentage_of_time`
714
-
715
- **Parameters**
716
-
717
- * `feature_name` - The name of the feature
718
-
719
- * `percentage` - The percentage of time to enable
720
-
721
- **Request**
722
-
723
- ```
724
- curl -X POST -d "percentage=20" http://example.com/flipper/api/features/reports/percentage_of_time
725
- ```
726
-
727
- **Response**
728
-
729
- Successful enabling of a percentage of time will return a 200 HTTP status and the feature object as the response body.
730
-
731
- ```json
732
- {
733
- "key": "reports",
734
- "state": "conditional",
735
- "gates": [
736
- {
737
- "key": "boolean",
738
- "name": "boolean",
739
- "value": false
740
- },
741
- {
742
- "key": "groups",
743
- "name": "group",
744
- "value": []
745
- },
746
- {
747
- "key": "actors",
748
- "name": "actor",
749
- "value": []
750
- },
751
- {
752
- "key": "percentage_of_actors",
753
- "name": "percentage_of_actors",
754
- "value": 0
755
- },
756
- {
757
- "key": "percentage_of_time",
758
- "name": "percentage_of_time",
759
- "value": 20
760
- }
761
- ]
762
- }
763
- ```
764
- ### Disable Percentage of Time
765
-
766
- **URL**
767
-
768
- `DELETE /features/{feature_name}/percentage_of_time`
769
-
770
- **Parameters**
771
-
772
- * `feature_name` - The name of the feature
773
-
774
- **Request**
775
-
776
- ```
777
- curl -X DELETE http://example.com/flipper/api/features/reports/percentage_of_time
778
- ```
779
-
780
- **Response**
781
-
782
- Successful disabling of a percentage of time will set the percentage to 0 and return a 200 HTTP status and the feature object as the response body.
783
-
784
- ```json
785
- {
786
- "key": "reports",
787
- "state": "off",
788
- "gates": [
789
- {
790
- "key": "boolean",
791
- "name": "boolean",
792
- "value": false
793
- },
794
- {
795
- "key": "groups",
796
- "name": "group",
797
- "value": []
798
- },
799
- {
800
- "key": "actors",
801
- "name": "actor",
802
- "value": []
803
- },
804
- {
805
- "key": "percentage_of_actors",
806
- "name": "percentage_of_actors",
807
- "value": 0
808
- },
809
- {
810
- "key": "percentage_of_time",
811
- "name": "percentage_of_time",
812
- "value": 0
813
- }
814
- ]
815
- }
816
- ```
817
-
818
- ## Errors
819
- In the event of an error the Flipper API will return an error object. The error object will contain a Flipper-specific error code, an error message, and a link to documentation providing more information about the error.
820
-
821
- *example error object*
822
- ```json
823
- {
824
- "code": 1,
825
- "message": "Feature not found",
826
- "more_info": "https://github.com/jnunemaker/flipper/tree/master/docs/api#error-code-reference",
827
- }
828
- ```
829
- ### Error Code Reference
830
-
831
- #### 1: Feature Not Found
832
-
833
- The requested feature does not exist. Make sure the feature name is spelled correctly and exists in your application's database.
834
-
835
- #### 2: Group Not Registered
836
-
837
- The requested group specified by the `name` parameter is not registered. Information on registering groups can be found in the [Gates documentation](https://github.com/jnunemaker/flipper/blob/master/docs/Gates.md).
838
-
839
- #### 3: Percentage Invalid
840
-
841
- The `percentage` parameter is invalid or missing. `percentage` must be an integer between 0-100 inclusive and cannot be blank.
842
-
843
- #### 4: Flipper ID Invalid
844
-
845
- The `flipper_id` parameter is invalid or missing. `flipper_id` cannot be empty.
846
-
847
- #### 5: Name Invalid
848
-
849
- The `name` parameter is missing. Make sure your request's body contains a `name` parameter.