-
Notifications
You must be signed in to change notification settings - Fork 12
/
bucketing-api.yaml
804 lines (750 loc) · 23 KB
/
bucketing-api.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
openapi: 3.1.0
info:
title: DevCycle Bucketing API
description:
Documents the DevCycle Bucketing API (https://bucketing-api.devcycle.com/) which provides an API interface to
User Bucketing and for generated SDKs.
servers:
- url: https://bucketing-api.devcycle.com/
tags:
- name: EdgeDB
- name: Bucketing API
- name: Feature Opt-in
- name: OpenFeature Remote Evaluation API (OFREP)
description:
"See the OpenFeature documentation for more information: https://github.com/open-feature/protocol"
paths:
/v1/variables/{key}:
post:
summary: Get variable by key for user data
tags:
- Bucketing API
operationId: 'getVariableByKey'
security:
- bearerAuth: []
parameters:
- name: key
in: path
description: Variable key
required: true
schema:
type: string
requestBody:
$ref: '#/components/requestBodies/UserRequestBody'
responses:
200:
description: Variable response
content:
application/json:
schema:
$ref: '#/components/schemas/Variable'
400:
$ref: '#/components/responses/BadRequest'
401:
$ref: '#/components/responses/UnauthorizedError'
404:
$ref: '#/components/responses/NotFound'
500:
$ref: '#/components/responses/InternalServerError'
/v1/variables:
post:
summary: Get all variables by key for user data
tags:
- Bucketing API
security:
- bearerAuth: []
operationId: 'getVariables'
requestBody:
$ref: '#/components/requestBodies/UserRequestBody'
responses:
200:
description: Variables response
content:
application/json:
schema:
type: object
additionalProperties:
$ref: '#/components/schemas/Variable'
400:
$ref: '#/components/responses/BadRequest'
401:
$ref: '#/components/responses/UnauthorizedError'
404:
$ref: '#/components/responses/NotFound'
500:
$ref: '#/components/responses/InternalServerError'
/v1/features:
post:
summary: Get all features by key for user data
tags:
- Bucketing API
operationId: 'getFeatures'
security:
- bearerAuth: []
requestBody:
$ref: '#/components/requestBodies/UserRequestBody'
responses:
200:
description: Feature response
content:
application/json:
schema:
type: object
additionalProperties:
$ref: '#/components/schemas/Feature'
400:
$ref: '#/components/responses/BadRequest'
401:
$ref: '#/components/responses/UnauthorizedError'
404:
$ref: '#/components/responses/NotFound'
500:
$ref: '#/components/responses/InternalServerError'
/v1/track:
post:
summary: Post events to DevCycle for user
tags:
- Bucketing API
security:
- bearerAuth: []
operationId: 'postEvents'
requestBody:
$ref: '#/components/requestBodies/TrackRequestBody'
responses:
201:
description: Feature response
content:
application/json:
schema:
type: object
properties:
message:
type: string
400:
$ref: '#/components/responses/BadRequest'
401:
$ref: '#/components/responses/UnauthorizedError'
404:
$ref: '#/components/responses/NotFound'
500:
$ref: '#/components/responses/InternalServerError'
/v1/edgedb/{id}:
patch:
summary: Update EdgeDB data based on unique id and project id
tags:
- EdgeDB
parameters:
- in: path
name: id
schema:
type: string
required: true
description: A unique id used to fetch and update the EdgeDB data
- name: sdkKey
in: query
description: SDK Key as defined in the dashboard for your DevCycle environment.
One of the Authorization header or "sdkKey" query parameter is required to be set.
required: false
schema:
type: string
requestBody:
description: User properties to update the EdgeDB data
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UserDataEdgeDB'
responses:
200:
description: Client SDK API Response
content:
application/json:
schema:
$ref: '#/components/schemas/EdgeDBApiResponse'
400:
$ref: '#/components/responses/BadRequest'
401:
$ref: '#/components/responses/UnauthorizedError'
404:
$ref: '#/components/responses/NotFound'
500:
$ref: '#/components/responses/InternalServerError'
/v1/optInConfig:
get:
summary: Fetch opt-in config
description: Fetch a project config to display features available for Opt-in
tags:
- Feature Opt-in
parameters:
- name: sdkKey
in: query
description: SDK Key as defined in the dashboard for your DevCycle environment.
One of the Authorization header or "sdkKey" query parameter is required to be set.
required: false
schema:
type: string
- name: user_id
in: query
description: Unique id to identify the user
required: true
schema:
type: string
responses:
200:
description: Opt-in Config Response
content:
application/json:
schema:
$ref: '#/components/schemas/OptInConfigResponse'
400:
$ref: '#/components/responses/BadRequest'
401:
$ref: '#/components/responses/UnauthorizedError'
500:
$ref: '#/components/responses/InternalServerError'
/v1/optIns/:user_id:
put:
summary: Update opt-in preferences for a user
tags:
- Feature Opt-in
parameters:
- name: sdkKey
in: query
description: SDK Key as defined in the dashboard for your DevCycle environment.
One of the Authorization header or "sdkKey" query parameter is required to be set.
required: false
schema:
type: string
requestBody:
description: A map of feature IDs to boolean values. The value should be true if the user has opted in, false otherwise
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UserOptInData'
responses:
200:
description: Opt-in Config Response
content:
application/json:
schema:
$ref: '#/components/schemas/OptInConfigResponse'
400:
$ref: '#/components/responses/BadRequest'
401:
$ref: '#/components/responses/UnauthorizedError'
500:
$ref: '#/components/responses/InternalServerError'
/ofrep/v1/evaluate/flags/{key}:
post:
tags:
- OpenFeature Remote Evaluation API (OFREP)
summary:
OFREP Single Flag Evaluation Request
description:
Return a single flag for a user context
parameters:
- name: key
in: path
required: true
schema:
type: string
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/ofrep-evaluationRequest'
responses:
'200':
description: OFREP successful evaluation response
content:
application/json:
schema:
$ref: '#/components/schemas/ofrep-evaluationSuccess'
'400':
description: Bad evaluation request
content:
application/json:
schema:
$ref: '#/components/schemas/ofrep-evaluationFailure'
'404':
description: Flag not found
content:
application/json:
schema:
$ref: '#/components/schemas/ofrep-flagNotFound'
'401':
description: Unauthorized - You need credentials to access the API
'403':
description: Forbidden - You are not authorized to access the API
'429':
description: Rate limit reached on the Flag Management System
headers:
Retry-Later:
description: Indicates when to retry the request again
schema:
type: string
format: date-time
examples:
- '2024-02-07T12:00:00Z'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/ofrep-generalErrorResponse'
/ofrep/v1/evaluate/flags:
post:
tags:
- OpenFeature Remote Evaluation API (OFREP)
summary:
OFREP Bulk Evaluation Request
description:
Return all flag values for a user context.
parameters:
- in: header
name: If-None-Match
description: The request will be processed only if ETag doesn't match any of the values listed.
schema:
type: string
required: false
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/ofrep-bulkEvaluationRequest'
responses:
'200':
description: OFREP successful evaluation response
headers:
ETag:
schema:
type: string
description: Entity tag used for cache validation
content:
application/json:
schema:
$ref: '#/components/schemas/ofrep-bulkEvaluationSuccess'
'304':
description: Bulk evaluation is not modified
'400':
description: Bad evaluation request
content:
application/json:
schema:
$ref: '#/components/schemas/ofrep-bulkEvaluationFailure'
'401':
description: Unauthorized - You need credentials to access the API
'403':
description: Forbidden - You are not authorized to access the API
'429':
description: Rate limit reached on the Flag Management System
headers:
Retry-Later:
description: Indicates when to retry the request again
schema:
type: string
format: date-time
examples:
- '2024-02-07T12:00:00Z'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/ofrep-generalErrorResponse'
components:
securitySchemes:
bearerAuth:
type: apiKey
in: header
name: Authorization
description: 'Enter your DevCycle SDK token'
schemas:
UserDataEdgeDB:
type: object
properties:
user_id:
description: Unique id to identify the user
type: string
email:
description: User's email used to identify the user on the dashaboard / target audiences
type: string
name:
description: User's name used to idenify the user on the dashaboard / target audiences
type: string
language:
description: User's language in ISO 639-1 format
additionalProperties:
type: string
maxLength: 2
country:
description: User's country in ISO 3166 alpha-2 format
additionalProperties:
type: string
maxLength: 2
customData:
description: User's custom data to target the user with, data will be logged to DevCycle for use in dashboard.
type: object
lastSeenDate:
description: Date the user was last seen being used, Unix epoch timestamp format
type: number
required:
- user_id
UserData:
type: object
properties:
user_id:
type: string
description: Unique id to identify the user
email:
type: string
description: User's email used to identify the user on the dashboard / target audiences
name:
type: string
description: User's name used to identify the user on the dashboard / target audiences
language:
type: string
description: User's language in ISO 639-1 format
maxLength: 2
country:
type: string
description: User's country in ISO 3166 alpha-2 format
maxLength: 2
appVersion:
type: string
description: App Version of the running application
appBuild:
type: string
description: App Build number of the running application
customData:
type: object
description: User's custom data to target the user with, data will be logged to DevCycle for use in dashboard.
privateCustomData:
type: object
description:
User's custom data to target the user with, data will not be logged to DevCycle
only used for feature bucketing.
createdDate:
type: number
description: Date the user was created, Unix epoch timestamp format
lastSeenDate:
type: number
description: Date the user was created, Unix epoch timestamp format
platform:
type: string
description: Platform the Client SDK is running on
platformVersion:
type: string
description: Version of the platform the Client SDK is running on
deviceModel:
type: string
description: User's device model
sdkType:
type: string
description: DevCycle SDK type
enum: [api, server]
sdkVersion:
type: string
description: DevCycle SDK Version
required:
- user_id
UserDataAndEventsBody:
type: object
properties:
events:
type: array
items:
$ref: '#/components/schemas/Event'
user:
$ref: '#/components/schemas/UserData'
UserOptInData:
type: object
additionalProperties:
type: boolean
Feature:
type: object
properties:
_id:
type: string
description: unique database id
key:
type: string
description: Unique key by Project, can be used in the SDK / API to reference by 'key' rather than _id.
type:
type: string
description: Feature type
enum: [ 'release', 'experiment', 'permission', 'ops' ]
_variation:
type: string
description: Bucketed feature variation ID
variationName:
type: string
description: Bucketed feature variation Name
variationKey:
type: string
description: Bucketed feature variation Key
evalReason:
type: string
description: Evaluation reasoning
required:
- _id
- key
- type
- _variation
Variable:
type: object
properties:
_id:
type: string
description: unique database id
key:
type: string
description: Unique key by Project, can be used in the SDK / API to reference by 'key' rather than _id.
type:
type: string
description: Variable type
enum: [ 'String', 'Boolean', 'Number', 'JSON' ]
value:
type: object
description: Variable value can be a string, number, boolean, or JSON
required:
- _id
- key
- type
- value
Event:
type: object
properties:
type:
type: string
description: Custom event type
target:
type: string
description: Custom event target / subject of event. Contextual to event type
date:
type: number
description: Unix epoch time the event occurred according to client
value:
type: number
description: Value for numerical events. Contextual to event type
metaData:
type: object
description: Extra JSON metadata for event. Contextual to event type
required:
- type
EdgeDBApiResponse:
type: object
properties:
message:
description: Response message of the request
type: string
required:
- message
OptInConfigResponse:
type: object
properties:
message:
description: Response message of the request
type: string
required:
- message
ErrorResponse:
type: object
properties:
statusCode:
type: number
description: Error response status code
message:
type: string
description: Error message
data:
type: object
description: Additional error information detailing the error reasoning
required:
- message
# OpenFeature Remote Evaluation API Schemas
ofrep-bulkEvaluationRequest:
description: Evaluate multiple flags in one request
properties:
context:
$ref: '#/components/schemas/ofrep-context'
ofrep-bulkEvaluationSuccess:
description: Success response for the bulk evaluation request
type: object
properties:
flags:
type: array
items:
oneOf:
- $ref: "#/components/schemas/ofrep-evaluationSuccess"
- $ref: '#/components/schemas/ofrep-evaluationFailure'
ofrep-bulkEvaluationFailure:
description: Bulk evaluation failure response
properties:
errorCode:
type: string
description: An appropriate code specific to the bulk evaluation error. See https://openfeature.dev/specification/types#error-code
errorDetails:
type: string
description: Optional error details description for logging or other needs
required:
- errorCode
ofrep-evaluationRequest:
description: Flag evaluation request
properties:
context:
$ref: '#/components/schemas/ofrep-context'
ofrep-evaluationSuccess:
description: Flag evaluation success response.
allOf:
- properties:
key:
$ref: "#/components/schemas/ofrep-key"
reason:
type: string
enum: [ STATIC,TARGETING_MATCH,SPLIT,DISABLED,UNKNOWN ]
description: An OpenFeature reason for the evaluation
variant:
type: string
description: Variant of the evaluated flag value
metadata:
type: object
description: Arbitrary metadata supporting flag evaluation
- oneOf:
- $ref: "#/components/schemas/ofrep-booleanFlag"
- $ref: "#/components/schemas/ofrep-stringFlag"
- $ref: "#/components/schemas/ofrep-integerFlag"
- $ref: "#/components/schemas/ofrep-floatFlag"
- $ref: "#/components/schemas/ofrep-objectFlag"
ofrep-evaluationFailure:
description: Flag evaluation failure response
properties:
key:
$ref: '#/components/schemas/ofrep-key'
errorCode:
type: string
enum: [ PARSE_ERROR,TARGETING_KEY_MISSING,INVALID_CONTEXT,GENERAL ]
description: OpenFeature compatible error code. See https://openfeature.dev/specification/types#error-code
errorDetails:
$ref: '#/components/schemas/ofrep-errorDetails'
required:
- key
- errorCode
ofrep-flagNotFound:
description: Flag not found response
properties:
key:
$ref: '#/components/schemas/ofrep-key'
errorCode:
type: string
enum: [ FLAG_NOT_FOUND ]
errorDetails:
$ref: '#/components/schemas/ofrep-errorDetails'
required:
- key
- errorCode
ofrep-generalErrorResponse:
description: A general error response from the service
properties:
errorDetails:
$ref: '#/components/schemas/ofrep-errorDetails'
ofrep-key:
type: string
description: Feature flag key
examples:
- my-flag
ofrep-context:
type: object
description: Context information for flag evaluation
ofrep-booleanFlag:
description: A boolean typed flag value
properties:
value:
type: boolean
description: Flag evaluation result
required:
- value
ofrep-stringFlag:
description: A string typed flag value
properties:
value:
type: string
description: Flag evaluation result
examples:
- "my-flag-value"
required:
- value
ofrep-integerFlag:
description: An integer typed flag value
properties:
value:
type: integer
description: Flag evaluation result
examples:
- 3
required:
- value
ofrep-floatFlag:
description: A float typed flag value
properties:
value:
type: number
description: Flag evaluation result
examples:
- 3.1415
required:
- value
ofrep-objectFlag:
description: An object typed flag value
properties:
value:
type: object
description: Flag evaluation result
required:
- value
ofrep-errorDetails:
type: string
description: An error description for logging or other needs
requestBodies:
UserRequestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UserData'
TrackRequestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UserDataAndEventsBody'
responses:
# 400
BadRequest:
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
# 401
UnauthorizedError:
description: Missing 'sdkKey' query parameter or 'Authorization' header
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
# 404
NotFound:
description: Not Found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
# 500
InternalServerError:
description: Internal Server Error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'