forked from Nebo15/gandalf.api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
apiary.apib
1019 lines (760 loc) · 39.5 KB
/
apiary.apib
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
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
FORMAT: 1A
HOST: https://api.gndf.io/
# Gandalf Decision Engine
Gandalf is a Open-Source Decision Engine for Big-Data.
Source code is available in our [GitHub Account](https://github.com/Nebo15/gandalf.api/). It's split in two separate parts:
- [PHP, Laravel, MongoDB Back-End](https://github.com/Nebo15/gandalf.api/)
- [Angular.js GUI](https://github.com/Nebo15/gandalf.web/)
### Features
- Customizable - have the freedom to design a decision rules you need and to manage data structure on the fly in a easy to understand way.
- Split testing (aka. Champion Winner) - each table can have infinite number of different variants, you can allocate traffic between them and leave only best one later.
- Decision History - all decisions are saved with all metadata: request parameters, decision table at request moment of time and decision itself.
- Decision Analytics - you can review all decisions made by your tables and to analyze what rules is triggered more often.
- Revisions History - rollback any changes that was made by you or your collaborators.
- Tooling - debug your decision tables directly from Gandalf GUI.
- SASS-based Role Model and oAuth 2.0 - you can create projects and share access among users to them.
- Production-tested - several large NDA-closed PSP's and online lending platforms already use Gandalf.
### Support
We appreciate your feedback, feel free to send it to [Support Team](mailto:[email protected]).
# Use Cases
## Decision Table and Rules Engine
There are many cases when you need to make decision based on input data. One good example is a decision to approve or decline lending application. You can setup a set of cut-off risk rules to decline applications for a high-risk applicants or to use a decision table to specify which categories of users will receive a loan on automatic basis.
## Scoring Table
Instead of rule decision you can set a score point that will be added to a final result.
In a result you will get a total of all scores and you can make further decision based on this value.
## State Transition Rules for BPM
Sometimes you need to have very complex rules in your BPM-engine, that should tell you to which branch your task should be transitioned to. Use Gandalf to manage all those rules.
# Support
This project is continuously supported on behalf of our customers and as part of our own [SaaS-service](https://gndf.io/). We recommend to use it, you can create your own installation of Gandalf.
Feel free to submit tickets in our GitHub repos, we will respond shortly. And if you want some custom conditions, e.g. 99.9% SLA - [contact us](mailto:[email protected]).
# How does it work?
You simply create a decision or scoring table, define some rules and query this table via API.
It makes Gandalf suitable for anti-fraud, loan scoring, transaction scoring, risk management, and as part any other decision making processes.
# Tables
Decision table is the main entity in Gandalf. It consists of columns that describe API request structure, rows that represent decision-making logic, and cells which describe a single validation rule.
### Decision Table
Decision table will apply all rules one by one, until one rule is passed and return value in Decision column for this rule.
### Scoring Table
Scoring table will sum all values in Scoring column and return their total.
## Columns (Fields)
Column represent specific request parameter. You can add additional parameters on a fly by adding a column. After saving table with new column all future API request should provide data for it. (Or at least ```null```, if you want to sometimes omit some request parts.)
<aside class="notice">
All request parameters are required!
</aside>
However, API consumer can provide more data and you don't need to specify column for each of request fields, in this case we will skip unused ones. Best practice is to feed table with any data you have, so you can use it when you need without changing back-end.
Column can have following settings:
- ```Title``` - human-readable string that describes field in interface.
- ```Field API Key``` - field name from witch data will be taken. For example, if you add a field with key ```name``` than all API consumers should provide JSON with this field: ```{"name": "Some User Name"}```.
- ```Type``` - type of data that will be submitted in this field. ```String```, ```Numeric``` or ```Boolean```.
### Presets
You can modify field value for table rows by adding field preset. For example, you have field called salary and it's too routine to add a "salaries greater than 1000" condition in each row, instead you can create preset that turns ```Numeric``` salary into ```Boolean``` type and simply turn on this validation in each rule.
It should look something like this:
- ```Title``` = ```Sufficient Salary```;
- ```Field API Key``` = ```salary```;
- ```Type``` = ```Numeric```;
- ```Preset Condition``` = ```greater than```;
- ```Preset Value``` = ```1000```.
By checking checkbox below ```Low Salary``` column in a row, you will make sure that this row won't pass check untill ```salary``` is greater than ```1000```.
## Rows (Rules)
Row represents a single rule in decision table. All rows are checked in order it was defined. (You can reorder it by drag'n'drop.) Basically, you can think about relation between rows as ```OR``` logical operators (or as ```else if```'s).
Row will return value selected in "Decision" column only if all validation rules in it have passed. Rules are checked in a same order as you see them in a table. You can reorder them by drug'n'drop.
If no one of defined rows passed all conditions, then we will return ```final_decision``` that equals a value specified in "Default Decision" dropdown.
> ```
IF rule1 then return rule1.decision
ELSEIF rule2 then return rule2.decision
ELSEIF rule3 then return rule3.decision
ELSEIF ruleN then return ruleN.decision
ELSE default return default.decision
```
## Cells (Conditions)
All cells in a row represent validations in an ```AND``` logical operator style (or you can thing about them as a bunch of conditions joined with ```&&``` inside ```if``` statement).
Sometimes you have a big table and in some rows you prefer to skip some validations. For this case you can select special validation rule called ```is set```. Logically it means that ```{field_name} is set``` and this condition will always pass validation.
> ```
IF rule1(cellCondition1 && cellCondition2 && cellConditionN) then return rule1.decision
ELSEIF ruleN(cellCondition1 && cellCondition2 && cellConditionN) then return ruleN.decision
ELSE default return default.decision
```
### Available Conditions
Available rules can differ based on a column type. Generally you should consider all rules logic as follows:
```{request_field_vale} {condition} {condition_value}```. For some conditions you can omit their value.
String fields support following conditions:
- ```=``` - validation will pass if field value equals specified value.
- ```!=``` - validation will pass if field value does not equal specified value.
- ```in``` - validation will pass if field value eqals to one of listed values. Separate values by comma with space. If searched string have comma you can surround value by single qoute. For example: ```d,e``` in ```a, b, c, 'd,e'``` will return true.
- ```not in``` - validation will pass if field value does not eqal to any of listed values.
- ```contains``` - validation will pass if field value is contains specified value.
- ```is set``` - validation will always pass. (Use it to skip some columns.)
- ```is null``` - validation will pass if field value equals ```null```. (Use it check if some column is skipped.)
Numeric supports:
- ```=``` - validation will pass if field value equals specified value.
- ```>``` - validation will pass if field value is greater than specified value.
- ```>=``` - validation will pass if field value is greater or equal to a specified value.
- ```<``` - validation will pass if field value is less than specified value.
- ```<=``` - validation will pass if field value is less or equal to a specified value.
- ```!=``` - validation will pass if field value does not equal specified value.
- ```in``` - validation will pass if field value eqals to one of listed values. Separate values by comma with space. If searched string have comma you can surround value by single qoute. For example: ```d,e``` in ```a, b, c, 'd,e'``` will return true.
- ```not in``` - validation will pass if field value does not eqal to any of listed values.
- ```is set``` - validation will always pass. (Use it to skip some columns.)
- ```is null``` - validation will pass if field value equals ```null```. (Use it check if some column is skipped.)
Boolean supports:
- ```true``` - will pass if field value is ```true```, ```1```, ```"1"``` or ```'1'```.
- ```false``` - will pass if field value is ```false```, ```0```, ```"0"``` or ```'0'```.
- ```is set``` - validation will always pass. (Use it to skip some columns.)
- ```is null``` - validation will pass if field value equals ```null```. (Use it check if some column is skipped.)
## Revisions
All changes that is made to a table is saved in Revisions history. You can see who changed what, and rollback to any previous state of the table.
Rollback will create a new Revision, so it can be canceled.
## Split Testing (aka Champion Winner)
Each table can have infinite number of variants, all of them share same fields (and request structure), but their rules can be totally different.
It allows to apply scientific method in managing your design rules: you have a hyphotesis, you create a variant for it, test and make analytical decision on whatever if was true and should influence main decision flow.
Requests to the table can have different types of traffic allocation between variants:
- ```First``` - request will always hit the first version of table. This will turn off split testing.
- ```Percent``` - allows you to manually set how much requests (in percentage) will receive each table variant.
- ```Random``` - randomly distribute requests between all variants.
## Decision Analytics
Each time Decision Table is called we will calculate how many times single condition was true, and how many times each rule returned it's decision. It allows you to see what rules work in real life, and to find ways to optimize your table.
# Decision History
All successful API request will lead to creating a Decision. You can find all Decisions in "Hisotry" tab.
Decision shows all request parameters, decision engine response and decision table that was applied when request was made. It means that whenever you change your decision table, it won't affect history and you still will be able to understand decision flow for each moment of time.
You can retry request on a latest table version by clicking "Debug" in request well.
# Installation Guide
Both Front-End and Back-End contains:
- Vagrantfile that allows to easily run local copy of Gandalf on your computer.
- Puppet scripts that allows to install on any Ubuntu server all software that is required for Gandalf.
## Starting with Vagrant
You can use [Vagrant](https://www.vagrantup.com/) to intialize a development environment. Simply install it, ```cd``` into your project directory and run:
```
vagrant up
```
## Configuring production environment
We use [Puppet](https://puppetlabs.com/puppet/puppet-open-source) as our configuration tool. Scripts located in [/puppet](https://github.com/Nebo15/gandalf.api/tree/master/puppet) directory of this repo. You can deploy code to your server and simply run:
```
set -o nounset -o errexit -o pipefail -o errtrace
trap 'error "${BASH_SOURCE}" "${LINENO}"' ERR
echo 127.0.0.1 gandalf.yourdomain.com | sudo tee -a /etc/hosts
sudo /bin/bash puppet/initial/init.sh -u "www-data"
```
# Story behind Gandalf
We - are production oriented team, and we work for a fintech company. Almost all project that we created need a decision engine that reduces business risks. And all solutions we can find is ether old and ugly, or very expensive. So we decided to create free open-source alternative, that will be scalable, reliable and flexible enough to cover 95% of cases.
To make is suitable for Big Data we decided to build it on top of use very reliable open-source database MongoDB, that have good sharding capabilities and easy to maintain.
Also we believe that vendor-lock is a bad thing, so we published all source code on a MIT license, so you are free to change it as you wish.
Done by [Nebo #15](http://nebo15.com/).
# Group Errors
General error response contains **Meta** object with properties:
* `code` - HTTP response code
* `error` - short error code
* `message` - (optional) human-readable error message
```json
{
"meta": {
"code": 404,
"error": "not_found",
"error_message": "Resource not found"
}
}
```
## Available errors
| Code | Error code | Message | Comments |
|------|-----------------------|-------------------------------------------------|-----------------------------------------------------------------------------------------|
| 400 | bad_request | Depends on the context | |
| 400 | invalid_app_header | You should set correct 'X-Application' header | |
| 400 | duplicate_user | Duplicate user | |
| 401 | unauthorized | Unauthorized | |
| 403 | access_denied | Depends on the context | Additional property `scopes`: array of scopes, e.g.: ```scopes: [is_admin, readable]``` |
| 403 | admin_not_activated | Project owner is not activated, try again later | |
| 404 | not_found | Resource not found | |
| 404 | table_not_found | Table not found | |
| 404 | variant_not_found | Variant not found | |
| 404 | decision_not_found | Decision not found | |
| 404 | changelog_not_found | Changelog not found | |
| 404 | token_not_found | Token not found | |
| 405 | method_not_allowed | Method Not Allowed | Wrong HTTP Method, e.g. required POST, sent GET |
| 422 | token_expired | Token expired. Refresh or generate new token | |
| 422 | validation | Validation failed | Contains additional property `data`. See example below |
| 500 | internal_server_error | | Server error
## Validation error response
Response contains property **data**, where described all invalid params.
You can see in response properties digits `variants.0.rules`, this is an array index of fields, that contains invalid data.
```json
{
"meta": {
"code": 422,
"error": "validation",
"error_message": "Validation failed"
},
"data": {
"variants.0.default_decision": [
"The variants.0.default decision field is required."
],
"variants.0.rules": [
"The variants.0.rules field is required."
],
"matching_type": [
"The matching type field is required."
],
"fields": [
"The fields field is required."
]
}
}
```
# Group User
## Users [/api/v1/admin/users]
### List All Users [GET]
+ Parameters
+ name: John (string) - Parameter searching users by usernames or emails. If name == jo, in the response users will be with usernames which starts on jo, Jo, JO. Searching by email enabled just when parameter has @
+ size: 10 (number) - Amount of items on page
+ page: 1 (number) - current page
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (array[UserList])
+ paging (Paging)
### Create User [POST]
+ Request (application/json)
+ Attributes (UpdateUser)
+ username: John.Smith (string) - Length 2-32 /^ [a-zA-Z0-9-_\.]+$/
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (User)
## Validate Username [/api/v1/admin/users/username]
### Validate Username [GET]
+ Parameters
+ username: John (string) - Username for validation
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
## Current User [/api/v1/users/current]
### Info about current user [GET]
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (User)
### Update user [PUT]
+ Request (application/json)
+ Attributes (UpdateUser)
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (User)
## Verify Email [/api/v1/users/verify/email]
### Verify Email [POST]
+ Request (application/json)
+ Attributes
+ token: $2y$10$.lp0OGb.nJSt... (string, required) - Token for verification email
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (User)
## Resend Email Verify Token [/api/v1/users/verify/email/resend]
Resend verify token to user email
### Resend [POST]
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
## Reset password [/api/v1/users/password/reset]
### Get reset password url with token [POST]
Send reset password url with token to User.email
+ Request (application/json)
+ Attributes
+ email: [email protected] (string, required)
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
### Change user password by token [PUT]
+ Request (application/json)
+ Attributes
+ token: $2y$10$.lp0OGb.nJSt... (string, required) - Token for password reset
+ password: newP@s$w0rd (string, required) - New user password
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (User)
## Invite User [/api/v1/invite]
### Create invitation for user to the project [POST]
+ Request (application/json)
+ Attributes
+ email: [email protected] (string, required) - Email for invitation
+ role: manager (string, required) Role of user in project
+ scope: read, write (array, required) - Array of user scopes
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (UserInvitation)
## Get User Access Token [/api/v1/oauth]
Get user access token, grant_type password scenario
**Every request should be with Access Token**
**-H 'Authorization: token_type access_token_here'**
### Get User Access Token [POST]
+ Request (application/json)
+ Attributes
+ `grant_type`: password, refresh_token (enum[string], required) - Grant Type
+ username: John (string) - Username or user email, required if grant_type == password
+ password: p@s$w0rd (string) - User password, required if grant_type == password
+ `refresh_token`: %4y$10$;lp8OGb.nAct... (string) - Refresh token, required if grant_type == refresh_token
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (AccessToken)
# Group Projects
## Projects [/api/v1/projects]
### List All Projects [GET]
+ Parameters
+ size: 10 (number) - Amount of items on page
+ page: 1 (number) - current page
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (array[Project])
+ paging (Paging)
### Create Project [POST]
Can create project and in the feature link tables to it.
When you created project, your feature requests should be with Header
**-H 'X-Application: project_id'**
+ Request (application/json)
+ Attributes (CreateProject)
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (Project)
### Update Project [PUT]
+ Request (application/json)
+ Attributes (CreateProject)
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (Project)
### Delete Project [DELETE]
***WARNING!!!*** This method will delete all Tables and Groups which connected to the project
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
## Export Project [/api/v1/projects/export]
### Export Project [GET]
Creates tar.gz archive with all Tables, Decisions and Changelogs documents.
Download link will be available within 24 hours.
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data
+ url: `http://gndf.io/dump/2016-07-01_13:00:58-$2y$10$MlqjEVA1D3CxS.tar.gz` (string) - Download link
## Get Current Project [/api/v1/projects/current]
### Get info about current project [GET]
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (Project)
## Project Consumers [/api/v1/projects/consumers]
### Create consumer [POST]
Every into existing project user can create consumer with own scopes.
For login as consumer you should make Basic Auth client_id:client_secret
+ Request (application/json)
+ Attributes
+ description: Bot (string, required) - Description of consumer
+ scope: read,check (array, required) - Scopes of consumer
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (array[Consumer])
### Get consumer [GET]
Get list of consumers for project
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (array[Consumer])
### Update consumer [PUT]
+ Request (application/json)
+ Attributes
+ `client_id`: clientId (string, required) - Client_id from consumer info
+ description: Bot (string, required) - Description of consumer
+ scope: read,check (array, required) - Scopes of consumer
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (array[Consumer])
### Delete consumer [DELETE]
Remove consumer from the project by client_id
+ Request (application/json)
+ Attributes
+ `client_id`: clientId (string, required) - Client_id from consumer info
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (array[Consumer])
## Project Users [/api/v1/projects/users]
### Get Info About Current User [GET]
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (ProjectUser)
### Add User To Project [POST]
Adding existing user to the current project. Share project with other users with different scopes
+ Request (application/json)
+ Attributes (CreateProjectUser)
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (Project)
### Update Project User [PUT]
+ Request (application/json)
+ Attributes (CreateProjectUser)
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (Project)
### Delete User From Project [DELETE]
+ Request (application/json)
+ Attributes
+ user_id: 56c31536a60ad644060041af (string, required) - ID of existing User
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (Project)
## Project admin [/api/v1/projects/users/admin]
### Set admin rights [POST]
Set admin rights and access level to another user
**Admin role is Required**
+ Request (application/json)
+ Attributes
+ user_id: 56c31536a60ad644060041af (string, required) - ID of existing User
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (Project)
# Group Table
Resources related to questions in the API.
Warning! If you don't pass _id, new MongoID will be generated, EVEN for existing document!
## Tables [/api/v1/admin/tables]
### Create Table [POST]
Available rules conditions are:
* `$is_set` - field key exists in request and its value can be any
* `$is_null` - **(null)** value must be NULL
* `$eq` - **(string, numeric, boolean)** value must be EQUAL to the condition value
* `$ne` - **(string, numeric, boolean)** value must be NOT EQUAL to the condition value
* `$gt` - **(numeric)** value must be GREATER THAN condition value
* `$gte` - **(numeric)** value must be GREATER THAN OR EQUAL to condition value
* `$lt` - **(numeric)** value must be LESS THAN to condition value
* `$lte` - **(numeric)** value must be LESS THAN OR EQUAL to condition value
* `$between` - **(numeric)** value must be in range of condition value. Condition value must be separated by semicolon: *12,3;30*
* `$in` - **(string, numeric)** value must be one of the following in condition value. Condition value must be separated by comma: *10.8,'hello world'*
* `$nin` - **(string, numeric)** value must NOT be one of the following in condition value. Condition value must be separated by comma: *10.8,'hello world'*
+ Request (application/json)
+ Attributes (Table)
+ Response 201 (application/json)
+ Attributes (object)
+ meta
+ code: 201 (number) - HTTP response code
+ data (Table)
### List All Tables [GET]
+ Parameters
+ title: Gandalf (string) - Filter by Table.title
+ description: Description (string) - Filter by table description
+ `matching_type`: scoring (string) - Filter by Table.matching_type
+ size: 10 (number) - Amount of items on page
+ page: 1 (number)
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (array[TableList])
+ paging (Paging)
## Table by ID [/api/v1/admin/tables/{id}]
### Get [GET]
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (Table)
### Update [PUT]
+ Request (application/json)
+ Attributes (Table)
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (Table)
### Delete [DELETE]
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
## Table Copy [/api/v1/admin/tables/{id}/copy]
Create new Table from existing Table by id
### Copy [POST]
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (Table)
## Table Analytics [/api/v1/admin/tables/{id}/{variant_id}/analytics]
Get Table analytics by all made Decisions
### Get [GET]
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (TableWithAnalytics)
# Group Decision
## Decisions All List [/admin/decisions]
### Decisions All List [GET]
+ Parameters
+ size: 1000 (number) - Amount of items on page
+ page: 1 (number) - current page
+ table_id: 576a80edce3c0c16be4d0c4d (string) - Filter by Table
+ variant_id: 576a7f01ce3c0c02ed0e5d4f (string) - Filter by Variant
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (array[Decision])
+ paging (Paging)
## Decisions By ID [/admin/decisions/{id}]
### Get Decision[GET]
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (Decision)
## Decisions Make [/tables/{id}/decisions]
### Make [POST]
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (DecisionConsumer)
# Group Changelog
## Changelog Tables List [/api/v1/admin/changelog/tables]
### Changelog Tables List [GET]
+ Parameters
+ size: 1000 (number) - Amount of items on page
+ page: 1 (number) - current page
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (array[Changelog])
+ paging (Paging)
## Changelog By Table [/api/v1/admin/changelog/tables/{id}]
Get Changelog by specific Table
### Changelog By Table [GET]
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data (array[Changelog])
## Changelog Tables Diff [/api/v1/admin/changelog/table/{id}/diff]
View changes between two Tables.
### Changelog Tables Diff [GET]
+ Parameters
+ compare_with: 56c31536a60ad644060041af (string, required) - `Changelog ID. View changes relative from current (if not passed *original* parameter) Table state to passed Table state`
+ original: 46a31536a60ad644060231aa (string) - Changelog ID. Set Table state, that will be compared with *compare_with* Table state
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data
+ original
(ChangelogTablesDiff)
+ compare_with
(arrayChangelogTablesDiff)
## Changelog Table Rollback [/api/v1/admin/changelog/tables/{table_id}/rollback/{changelog_id}]
Rollback Table to some state that described in passed Changelog
## Changelog Table Rollback [POST]
+ Response 200 (application/json)
+ Attributes (object)
+ meta
+ code: 200 (number) - HTTP response code
+ data
+ reverted
(Table)
## Data Structures
### TableList
+ _id: 56c31536a60ad644060041af (string) - MongoID
+ `matching_type`: decision,scoring (enum[string], required) - Matching type for Table
+ `decision_type`: alpha_num,numeric,string,json (enum[string], required) - Validation rule for Variant.default_decision and Rule.than fields
+ title: Table title (string) - Table title
+ description: Table title (string) - Table description
+ variants: (array[VariantList])
### Table (TableList)
+ variants_probability: first,random,percent(enum[string]) - Variants check strategy
+ fields (array[Field])
+ variants (array[Variant])
### Field
+ _id: 56c31536a60ad644060041af (string) - MongoID
+ key: salary (string, required) - API Field key for request
+ title: Field title (string, required) - Field title
+ type: numeric,boolean,string (enum[string], required) - Available field data types
+ preset (object) - Preset object. You can modify field value for table rows by adding field preset
+ condition: $is_set,$is_null,$eq,$ne,$gt,$gte,$lt,$lte,$between,$in,$nin (enum[string], required)
+ value: 1000 (string, required) - Value type can be different depends on condition
### VariantList
+ _id: 56c31536a60ad644060041af (string) - MongoID
+ title: Variant title (string) - Variant title
+ description: Variant description (string) - Variant description
### Variant (VariantList)
+ default_decision: Decline (string, required)
+ default_title: No one Rule matched (string) - When Table processing does not match any rule, this field will be set by default to Decision.title
+ default_description: No one Rule matched (string) - When Table processing does not match any rule, this field will be set by default to Decision.description
+ probability: 30 (number) - Required when **Table.variants_probability == variants_probability**, percent of probability. Sum of all probabilities should be equal to 100
+ rules (array[Rule], required)
### Rule
+ _id: 56c31536a60ad644060041af (string) - MongoID
+ than: Approve (string, required)
+ title: Rule title (string, required)
+ description: Rule description (string, required)
+ conditions (array[Condition], required)
### Condition
+ _id: 56c31536a60ad644060041af (string) - MongoID
+ field_key: salary (string, required)
+ condition: $is_set,$is_null,$eq,$ne,$gt,$gte,$lt,$lte,$between,$in,$nin (enum[string], required)
+ value: unemployed | 1000 | true (string, required)
### TableWithAnalytics (Table)
+ variants (array[VariantWithAnalytics])
### VariantWithAnalytics (Variant)
+ rules (array[RuleWithAnalytics], required)
### RuleWithAnalytics (Rule)
+ conditions (array[ConditionWithAnalytics], required)
### ConditionWithAnalytics (Condition)
+ probability: 0.67 (number) - Probability value between 0-1, where 1 is 100% matched result
+ requests: 217 (number) - Requests amount for current condition.
### DecisionConsumer
+ _id: 56c31536a60ad644060041af (string) - MongoID
+ title: Decision title (string) - Decision title
+ description: Decision description (string) - Decision description
+ final_decision: Approve (string) - Depends of the Table.matching_type could be as highest row in a table with all validations passed or sum of scoring points",
+ application: gandalf (string) - Application id
+ request
+ salary: 1000 (string) - All passed parameters from request
+ table
+ _id: 56c31536a60ad644060041af (string) - MongoID
+ matching_type: decision,scoring (enum[string], required) - Matching type for Table
+ title: Table title (string) - Table title
+ description: Table title (string) - Table description
+ variant
+ _id: 56c31536a60ad644060041af (string) - MongoID
+ title: Variant title (string) - Variant title
+ description: Variant description (string) - Variant description
+ rules
+ title: Rule title (string, required)
+ description: Rule description (string, required)
+ decision: Approve (string) - Matched Rule decision or Variant.default_decision
+ created_at: 2016-02-16 14:15:30 (string)
+ updated_at: 2016-02-16 14:15:30 (string)
### Decision (DecisionConsumer)
+ meta: custom, meta, data (array) - Custom meta data
+ default_decision: Decline (string, required) - Value from Table.default_decision
+ fields (array[Field])
+ rules (array[DecisionRule])
### DecisionRule (Rule)
+ decision: Approve (string) - Matched Rule decision or Variant.default_decision
+ conditions (array[Condition], required)
### DecisionCondition (Condition)
+ matched: true (boolean) - Is current condition matched
### Changelog
+ _id: 56c31536a60ad644060041af (string) - MongoID
+ author: Admin (string) - Who made changes
+ model
+ _id: 56c31536a60ad644060041af (string) - MongoID
+ table: table (string) - Model table name
+ created_at: 2016-02-16 14:15:30 (string)
+ updated_at: 2016-02-16 14:15:30 (string)
### ChangelogTablesDiff (Changelog)
+ model
+ _id: 56c31536a60ad644060041af (string) - MongoID
+ table: table (string) - Model table name
+ attributes (Table)
### Project
+ _id: 56c31536a60ad644060041af (string) - MongoID
+ title: Gandalf (string) - Project title
+ description: Gandalf API Description(string) - Project description
+ settings:
+ customField: some value (string) - Custom settings
+ show_meta: false (boolean) - Custom settings
+ users (array[ProjectUser])
+ consumers (array[Consumer])
### ProjectUser
+ _id: 56c31536a60ad644060041af (string) - MongoID
+ user_id: 56c31536a60ad644060041af (string) - Unique identifier of a User, MongoID
+ role: manager (string) Role of user in project
+ scope: read, write, ... (array) - Array of user scopes
+ username: Freddy (string)
+ email: [email protected] (string) - User email
### Consumer
+ _id: 56c31536a60ad644060041af (string) - MongoID
+ client_id: fe5fe8d15bb7a6a0daef36d2843c547c6d594b0c (string) - Client ID
+ client_secret: a7c70da3246a436bde66101d65741f9adf570726 (string) - Client secret
+ description: Description of project (string) - Optional description of client
+ scope: read, write, ... (array) - Array of user scopes
### UserList
+ _id: 56c31536a60ad644060041af (string) - MongoID
+ username: Freddy (string)
### User (UserList)
+ description: Some description (string) - Description of the matched rule or Table.default_description
+ email: [email protected] (string) - User email
+ created_at: 2016-02-16 14:15:30 (string)
+ updated_at: 2016-02-16 14:15:30 (string)
+ access_tokens (array[AccessToken])
+ refresh_tokens (array[RefreshToken])
### UserInvitation
+ role: manager (string) Role of user in project
+ project
+ _id: 56c31536a60ad644060041af (string) - MongoID
+ title First project (string) - Project title
+ scope: read, write (array) - Array of user scopes
+ email: [email protected] (string) - User email
+ created_at: 2016-02-16 14:15:30 (string)
+ updated_at: 2016-02-16 14:15:30 (string)
### AccessToken
+ access_token: 2fc5a4e7a91771ca312c79e0ad2cc4c49d3b065d (string) - Unique access token for current user
+ expires_in: 360 (number) - Token lifetime, seconds
+ token_type: Bearer (string) - Type of access token
+ refresh_token: 8bcc30bf6ce74ddaf0ec5eff5a51141c7ba65ef9 (string) - Unique refresh token linked to some access token for current user
### RefreshToken
+ _id: 56c31536a60ad644060041af (string) - MongoID
+ refresh_token: 8bcc30bf6ce74ddaf0ec5eff5a51141c7ba65ef9 (string) - Unique refresh token linked to some access token for current user
+ client_id: SomeId (string) - Client id for refresh token
### Paging
+ size: 15 (number) - items per page