flipper 0.22.0 → 0.28.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +1 -0
  3. data/.github/dependabot.yml +6 -0
  4. data/.github/workflows/ci.yml +26 -20
  5. data/.github/workflows/examples.yml +62 -0
  6. data/.rspec +1 -0
  7. data/.tool-versions +1 -0
  8. data/Changelog.md +152 -3
  9. data/Dockerfile +1 -1
  10. data/Gemfile +9 -6
  11. data/README.md +15 -67
  12. data/Rakefile +4 -2
  13. data/benchmark/enabled_ips.rb +10 -0
  14. data/benchmark/enabled_multiple_actors_ips.rb +20 -0
  15. data/benchmark/enabled_profile.rb +20 -0
  16. data/benchmark/instrumentation_ips.rb +21 -0
  17. data/benchmark/typecast_ips.rb +19 -0
  18. data/docker-compose.yml +37 -34
  19. data/docs/README.md +1 -0
  20. data/docs/images/banner.jpg +0 -0
  21. data/examples/api/basic.ru +3 -4
  22. data/examples/api/custom_memoized.ru +3 -4
  23. data/examples/api/memoized.ru +3 -4
  24. data/examples/dsl.rb +3 -3
  25. data/examples/enabled_for_actor.rb +4 -2
  26. data/examples/instrumentation.rb +1 -0
  27. data/examples/instrumentation_last_accessed_at.rb +38 -0
  28. data/flipper.gemspec +2 -2
  29. data/lib/flipper/actor.rb +4 -0
  30. data/lib/flipper/adapter.rb +23 -7
  31. data/lib/flipper/adapters/dual_write.rb +10 -16
  32. data/lib/flipper/adapters/failover.rb +83 -0
  33. data/lib/flipper/adapters/failsafe.rb +76 -0
  34. data/lib/flipper/adapters/http/client.rb +18 -12
  35. data/lib/flipper/adapters/http/error.rb +19 -1
  36. data/lib/flipper/adapters/http.rb +14 -4
  37. data/lib/flipper/adapters/instrumented.rb +25 -2
  38. data/lib/flipper/adapters/memoizable.rb +27 -18
  39. data/lib/flipper/adapters/memory.rb +56 -39
  40. data/lib/flipper/adapters/operation_logger.rb +16 -3
  41. data/lib/flipper/adapters/poll/poller.rb +2 -0
  42. data/lib/flipper/adapters/poll.rb +39 -0
  43. data/lib/flipper/adapters/pstore.rb +2 -5
  44. data/lib/flipper/adapters/sync/interval_synchronizer.rb +1 -6
  45. data/lib/flipper/adapters/sync/synchronizer.rb +2 -1
  46. data/lib/flipper/adapters/sync.rb +9 -15
  47. data/lib/flipper/dsl.rb +9 -11
  48. data/lib/flipper/errors.rb +3 -20
  49. data/lib/flipper/export.rb +26 -0
  50. data/lib/flipper/exporter.rb +17 -0
  51. data/lib/flipper/exporters/json/export.rb +32 -0
  52. data/lib/flipper/exporters/json/v1.rb +33 -0
  53. data/lib/flipper/feature.rb +32 -26
  54. data/lib/flipper/feature_check_context.rb +10 -6
  55. data/lib/flipper/gate.rb +12 -11
  56. data/lib/flipper/gate_values.rb +0 -16
  57. data/lib/flipper/gates/actor.rb +10 -17
  58. data/lib/flipper/gates/boolean.rb +1 -1
  59. data/lib/flipper/gates/group.rb +5 -7
  60. data/lib/flipper/gates/percentage_of_actors.rb +10 -13
  61. data/lib/flipper/gates/percentage_of_time.rb +1 -2
  62. data/lib/flipper/identifier.rb +2 -2
  63. data/lib/flipper/instrumentation/log_subscriber.rb +7 -3
  64. data/lib/flipper/instrumentation/subscriber.rb +8 -1
  65. data/lib/flipper/instrumenters/memory.rb +6 -2
  66. data/lib/flipper/metadata.rb +1 -1
  67. data/lib/flipper/middleware/memoizer.rb +2 -12
  68. data/lib/flipper/poller.rb +117 -0
  69. data/lib/flipper/railtie.rb +23 -22
  70. data/lib/flipper/spec/shared_adapter_specs.rb +23 -0
  71. data/lib/flipper/test/shared_adapter_test.rb +24 -0
  72. data/lib/flipper/typecast.rb +28 -15
  73. data/lib/flipper/types/actor.rb +19 -13
  74. data/lib/flipper/types/group.rb +12 -5
  75. data/lib/flipper/version.rb +1 -1
  76. data/lib/flipper.rb +6 -4
  77. data/spec/fixtures/flipper_pstore_1679087600.json +46 -0
  78. data/spec/flipper/actor_spec.rb +10 -2
  79. data/spec/flipper/adapter_spec.rb +29 -4
  80. data/spec/flipper/adapters/dual_write_spec.rb +0 -2
  81. data/spec/flipper/adapters/failover_spec.rb +129 -0
  82. data/spec/flipper/adapters/failsafe_spec.rb +58 -0
  83. data/spec/flipper/adapters/http_spec.rb +64 -6
  84. data/spec/flipper/adapters/instrumented_spec.rb +28 -12
  85. data/spec/flipper/adapters/memoizable_spec.rb +30 -12
  86. data/spec/flipper/adapters/memory_spec.rb +3 -4
  87. data/spec/flipper/adapters/operation_logger_spec.rb +29 -12
  88. data/spec/flipper/adapters/pstore_spec.rb +0 -2
  89. data/spec/flipper/adapters/read_only_spec.rb +0 -1
  90. data/spec/flipper/adapters/sync/feature_synchronizer_spec.rb +0 -1
  91. data/spec/flipper/adapters/sync/interval_synchronizer_spec.rb +4 -5
  92. data/spec/flipper/adapters/sync/synchronizer_spec.rb +0 -1
  93. data/spec/flipper/adapters/sync_spec.rb +0 -2
  94. data/spec/flipper/configuration_spec.rb +0 -1
  95. data/spec/flipper/dsl_spec.rb +38 -12
  96. data/spec/flipper/export_spec.rb +13 -0
  97. data/spec/flipper/exporter_spec.rb +16 -0
  98. data/spec/flipper/exporters/json/export_spec.rb +60 -0
  99. data/spec/flipper/exporters/json/v1_spec.rb +33 -0
  100. data/spec/flipper/feature_check_context_spec.rb +17 -19
  101. data/spec/flipper/feature_spec.rb +76 -33
  102. data/spec/flipper/gate_spec.rb +0 -2
  103. data/spec/flipper/gate_values_spec.rb +2 -34
  104. data/spec/flipper/gates/actor_spec.rb +0 -2
  105. data/spec/flipper/gates/boolean_spec.rb +1 -3
  106. data/spec/flipper/gates/group_spec.rb +2 -5
  107. data/spec/flipper/gates/percentage_of_actors_spec.rb +61 -7
  108. data/spec/flipper/gates/percentage_of_time_spec.rb +2 -4
  109. data/spec/flipper/identifier_spec.rb +0 -1
  110. data/spec/flipper/instrumentation/log_subscriber_spec.rb +15 -6
  111. data/spec/flipper/instrumentation/statsd_subscriber_spec.rb +10 -1
  112. data/spec/flipper/instrumenters/memory_spec.rb +18 -1
  113. data/spec/flipper/instrumenters/noop_spec.rb +14 -8
  114. data/spec/flipper/middleware/memoizer_spec.rb +0 -23
  115. data/spec/flipper/middleware/setup_env_spec.rb +0 -2
  116. data/spec/flipper/poller_spec.rb +47 -0
  117. data/spec/flipper/railtie_spec.rb +73 -33
  118. data/spec/flipper/registry_spec.rb +0 -1
  119. data/spec/flipper/typecast_spec.rb +82 -4
  120. data/spec/flipper/types/actor_spec.rb +45 -46
  121. data/spec/flipper/types/boolean_spec.rb +0 -1
  122. data/spec/flipper/types/group_spec.rb +2 -3
  123. data/spec/flipper/types/percentage_of_actors_spec.rb +0 -1
  124. data/spec/flipper/types/percentage_of_time_spec.rb +0 -1
  125. data/spec/flipper/types/percentage_spec.rb +0 -1
  126. data/spec/flipper_integration_spec.rb +62 -51
  127. data/spec/flipper_spec.rb +7 -2
  128. data/spec/{helper.rb → spec_helper.rb} +4 -2
  129. data/spec/support/skippable.rb +18 -0
  130. data/spec/support/spec_helpers.rb +2 -6
  131. metadata +63 -19
  132. data/docs/Adapters.md +0 -124
  133. data/docs/Caveats.md +0 -4
  134. data/docs/Gates.md +0 -167
  135. data/docs/Instrumentation.md +0 -27
  136. data/docs/Optimization.md +0 -137
  137. data/docs/api/README.md +0 -884
  138. data/docs/http/README.md +0 -36
  139. data/docs/read-only/README.md +0 -24
data/docs/api/README.md DELETED
@@ -1,884 +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
- ### Check if features are enabled for an actor
819
-
820
- **URL**
821
-
822
- `GET /actors/{flipper_id}`
823
-
824
- **Parameters**
825
-
826
- * `keys` - comma-separated list of features to check
827
-
828
- **Request**
829
-
830
- ```
831
- curl -X GET http://example.com/flipper/api/actors/User;1?keys=my_feature_1,my_feature_2
832
- ```
833
-
834
- **Response**
835
-
836
- Returns whether the actor with the provided flipper_id is enabled for the specififed feature keys.
837
- If no keys are specified all features are returned.
838
-
839
- ```json
840
- {
841
- "flipper_id": "User;1",
842
- "features": {
843
- "my_feature_1": {
844
- "enabled": true,
845
- },
846
- "my_feature_2": {
847
- "enabled": false,
848
- }
849
- }
850
- }
851
- ```
852
-
853
- ## Errors
854
- 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.
855
-
856
- *example error object*
857
- ```json
858
- {
859
- "code": 1,
860
- "message": "Feature not found",
861
- "more_info": "https://github.com/jnunemaker/flipper/tree/master/docs/api#error-code-reference",
862
- }
863
- ```
864
- ### Error Code Reference
865
-
866
- #### 1: Feature Not Found
867
-
868
- The requested feature does not exist. Make sure the feature name is spelled correctly and exists in your application's database.
869
-
870
- #### 2: Group Not Registered
871
-
872
- 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).
873
-
874
- #### 3: Percentage Invalid
875
-
876
- The `percentage` parameter is invalid or missing. `percentage` must be an integer between 0-100 inclusive and cannot be blank.
877
-
878
- #### 4: Flipper ID Invalid
879
-
880
- The `flipper_id` parameter is invalid or missing. `flipper_id` cannot be empty.
881
-
882
- #### 5: Name Invalid
883
-
884
- The `name` parameter is missing. Make sure your request's body contains a `name` parameter.