Unverified Commit 5b1d875e by thibault

Cerberus admin v1 specifications

parent 842a7fc8
docs/conception/v1/*.log
docs/conception/v1/*.out
docs/conception/v1/*.aux
docs/conception/v1/*.synctex.gz
This diff is collapsed. Click to expand it.
# Description
Cerberus admin is a Web UI which allows one to setup [Cerberus](https://gitlab.patrick.quaidesapps.com/shared/cerberus).
# How to setup your development environment
To work on Cerberus admin, you'll need a working instance of Cerberus. To ease your setup, we provide a functional infrastucure based on docker. By following steps below, you should get something ready to use quite easily.
## Requirements
### Docker and docker-compose
We do not explain how to install docker as it depends a lot of your personal setup.
We just remember below how you *can* install docker-compose:
```bash
sudo curl -L https://github.com/docker/compose/releases/download/1.19.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
```
### clone cerberus-admin project
```bash
git clone https://gitlab.patrick.quaidesapps.com/shared/cerberus-admin.git
```
### cerberus sources
Then, you'll need cerberus sources:
```bash
cd cerberus-admin
git clone https://gitlab.patrick.quaidesapps.com/shared/cerberus.git cerberus_docker/images/cerberus
```
## Launching cerberus
From cerberus-admin folder, you may get cerberus working simply by executing following commands:
```bash
cd cerberus_docker
sudo docker-compose up
```
## Check cerberus is available
Cerberus should be up now, you can check it by browsing following URLs:
* http://localhost:55000
* http://localhost:55000/explorer
The first should give you a response which looks like:
```json
{"started":"2018-02-22T22:39:49.174Z","uptime":2586.521}
```
The second URL gives you an "API explorer" for cerberus; this is a convenient tool to test requests on cerberus API. The "API explorer" is provided by [Strongloop](http://strongloop.com/).
## Import data
Your cerberus instance should have no data on first run. We provide some example data you can import in Cerberus databse.
### Import bulk data
Open your web browser on API explorer: http://localhost:55000/explorer/#!/Service/Service_import
Then, in the data field, paste the content of *cerberus_docker/data/data.json* then click "Try it out!".
It should create a service named "api" and also some features/functionalities/quotas associated to it.
You can check this by calling:
* GET /api/Features
* GET /api/Functionalities
* GET /api/PlanFeatures
* GET /api/PlanFunctionalities
* GET /api/Service
### Create an user
You may need to add an user:
POST http://localhost:55000/api/ServiceUsers
payload={"email":"test1@example.com"}
```json
{
"email": "test1@example.com",
"id": "5a8f4919f6eb0c0001da65b4"
}
```
### Fork a plan for a given user and a given service
Then fork a plan for a service for that user:
POST http://localhost:55000/api/Plans/forkFor
payload={"email": "test1@example.com", "plan": "Basic", "service": "api"}
```json
{
"user_plan": {
"name": "Basic",
"price": 100,
"startDate": "2018-02-22T22:52:17.862Z",
"id": "5a8f49a1f6eb0c0001da65b5",
"serviceId": "5a8f2eeb1c190e000136411a",
"serviceUserId": "5a8f4919f6eb0c0001da65b4"
}
}
```
### Make this user access a functionality
POST http://localhost:55000/api/ServiceUsers/could
payload={"email": "test1@example.com", "service": "api", "functionality": "addImageToAlbum"}
```json
{
"could": true
}
```
This should create an UserCounter:
GET /api/UserCounters
```json
[
{
"value": 1,
"keys": [],
"id": "5a8f4ad3f6eb0c0001da65cf",
"userQuotaId": "5a8f49a2f6eb0c0001da65cd"
}
]
```
\ No newline at end of file
{
"name": "api",
"features": [
{
"name": "imageBook",
"isLimited": true,
"functionalities": [{
"name": "addImageToBook",
"value": 1,
"isAvailable": true,
"isAllowedDefault": true
},{
"name": "removeImageFromBook",
"value": -1,
"isAvailable": true,
"isAllowedDefault": true
}]
},{
"name": "campaign",
"isLimited": true,
"functionalities": [{
"name": "addCampaign",
"value": 1,
"isAvailable": true,
"isAllowedDefault": true
},{
"name": "removeCampaign",
"value": -1,
"isAvailable": true,
"isAllowedDefault": true
}]
},{
"name": "campaignAlbum",
"isLimited": true,
"functionalities": [{
"name": "addAlbumToCampaign",
"value": 1,
"isAvailable": true,
"isAllowedDefault": true
},{
"name": "removeAlbumFromCampaign",
"value": -1,
"isAvailable": true,
"isAllowedDefault": true
}]
},{
"name": "campaignEndpoint",
"isLimited": true,
"functionalities": [{
"name": "addEndpointToCampaign",
"value": 1,
"isAvailable": true,
"isAllowedDefault": true
},{
"name": "removeEndpointFromCampaign",
"value": -1,
"isAvailable": true,
"isAllowedDefault": true
}]
},{
"name": "albumImage",
"isLimited": true,
"functionalities": [{
"name": "addImageToAlbum",
"value": 1,
"isAvailable": true,
"isAllowedDefault": true
},{
"name": "removeImageFromAlbum",
"value": -1,
"isAvailable": true,
"isAllowedDefault": true
}]
},{
"name": "albumAction",
"isLimited": true,
"functionalities": [{
"name": "addActionToAlbum",
"value": 1,
"isAvailable": true,
"isAllowedDefault": true
},{
"name": "removeActionFromAlbum",
"value": -1,
"isAvailable": true,
"isAllowedDefault": true
}]
},{
"name": "something",
"isLimited": false,
"functionalities": []
}
],
"plans":[
{
"name": "Limited",
"price": 0,
"features": [
{
"name": "imageBook",
"quotas": {
"name": "maxImageInBook",
"limit": 5
}
},
{
"name": "campaign",
"quotas": {
"name": "maxCampaign",
"limit": 1
}
},
{
"name": "campaignAlbum",
"quotas": {
"name": "maxAlbumInCampaign",
"limit": 1
}
},
{
"name": "campaignEndpoint",
"quotas": {
"name": "maxEndpointInCampaign",
"limit": 0
}
},
{
"name": "albumImage",
"quotas": {
"name": "maxImageInAlbum",
"limit": 1
}
},
{
"name": "albumAction",
"quotas": {
"name": "maxActionInAlbum",
"limit": 1
}
}
]
},
{
"name": "Basic",
"price": 100,
"features": [
{
"name": "imageBook",
"quotas": {
"name": "maxImageInBook",
"limit": 30
}
},
{
"name": "campaign",
"quotas": {
"name": "maxCampaign",
"limit": 5
}
},
{
"name": "campaignAlbum",
"quotas": {
"name": "maxAlbumInCampaign",
"limit": 10
}
},
{
"name": "campaignEndpoint",
"quotas": {
"name": "maxEndpointInCampaign",
"limit": 2
}
},
{
"name": "albumImage",
"quotas": {
"name": "maxImageInAlbum",
"limit": 15
}
},
{
"name": "albumAction",
"quotas": {
"name": "maxActionInAlbum",
"limit": 1
}
}
]
}
]
}
\ No newline at end of file
version: '2.1'
services:
mongo:
image: "mongo:latest"
ports:
- "27018:27017"
volumes:
- dbdata:/data/db
plm:
image: cerberus-plm:latest
build: "./images/cerberus-plm"
restart: always
ports:
- "65000:65000"
cerberus:
image: cerberus:latest
build: "./images/cerberus"
restart: always
ports:
- "55000:80"
depends_on:
- mongo
- plm
environment:
- PLM_URI=http://${HOST_IP:-172.17.0.1}:65000
volumes:
dbdata:
external: false
cerberus @ ffeb76fd
Subproject commit ffeb76fdae4c96503970d2b75c2830827592ee43
FROM ubuntu:latest
WORKDIR /plm
RUN apt update
RUN apt install wget -y
RUN wget https://gitlab.patrick.quaidesapps.com/thirdparts/esther-plm/-/jobs/21/artifacts/raw/pkg/esther-plm_1.9_linux_amd64.deb
RUN dpkg -i esther-plm_1.9_linux_amd64.deb
COPY plm.conf /plm/plm.conf
COPY services /plm/services
CMD ["esther-plm","-c","/plm/plm.conf"]
{
"services": [
{
"name": "cerberus",
"silent": false,
"configurationFile": "/plm/services/cerberus.json"
}
],
"watchdog": {
"delay": "1s",
"unreachable_limit": 1
},
"port": 65000
}
{
"listen_port": "80",
"uri": "localhost:80",
"prefix": "/",
"db": {
"mongo_host": "172.17.0.1",
"mongo_port": 27018,
"mongo_db": "cerberus",
"mongo_uri": "mongodb://172.17.0.1:27018/tests"
}
}
{
"count": 65
}
\ No newline at end of file
POST /api/ServiceUsers
payload={"email":"test1@example.com"}
{
"email": "test1@example.com",
"id": "5a8f4919f6eb0c0001da65b4"
}
POST /api/Plans/forkFor
payload={"email": "test1@example.com", "plan": "Basic", "service": "api"}
{
"user_plan": {
"name": "Basic",
"price": 100,
"startDate": "2018-02-22T22:52:17.862Z",
"id": "5a8f49a1f6eb0c0001da65b5",
"serviceId": "5a8f2eeb1c190e000136411a",
"serviceUserId": "5a8f4919f6eb0c0001da65b4"
}
}
POST /api/ServiceUsers/could
payload={"email": "test1@example.com", "service": "api", "functionality": "addImageToAlbum"}
{
"could": true
}
\ No newline at end of file
GET /api/Plans/59f2ef64d24efd45cbae57d6?filter={"include": {
"features": ["functionalities", "quotas"]}}
[
{
"name": "Basic",
"price": 100,
"defaultDuration": 0,
"id": "59f2ef64d24efd45cbae57d6",
"serviceId": "59f2ef64d24efd45cbae57c2",
"features": [
{
"name": "campaign",
"id": "59f2ef64d24efd45cbae57d8",
"featureId": "59f2ef64d24efd45cbae57c4",
"planId": "59f2ef64d24efd45cbae57d6",
"functionalities": [
{
"name": "removeCampaign",
"isAllowed": true,
"value": -1,
"id": "59f2ef64d24efd45cbae57e4",
"functionalityId": "59f2ef64d24efd45cbae57ca",
"planFeatureId": "59f2ef64d24efd45cbae57d8"
}
],
"quotas": [
{
"name": "maxCampaign",
"limit": 5,
"id": "59f2ef64d24efd45cbae57f5",
"planFeatureId": "59f2ef64d24efd45cbae57d8"
}
]
},
{
"name": "imageBook",
"id": "59f2ef64d24efd45cbae57da",
"featureId": "59f2ef64d24efd45cbae57c7",
"planId": "59f2ef64d24efd45cbae57d6",
"functionalities": [
{
"name": "addImageToBook",
"isAllowed": true,
"value": 1,
"id": "59f2ef64d24efd45cbae57e5",
"functionalityId": "59f2ef64d24efd45cbae57d3",
"planFeatureId": "59f2ef64d24efd45cbae57da"
},
{
"name": "removeImageFromBook",
"isAllowed": true,
"value": -1,
"id": "59f2ef64d24efd45cbae57e7",
"functionalityId": "59f2ef64d24efd45cbae57d0",
"planFeatureId": "59f2ef64d24efd45cbae57da"
}
],
"quotas": [
{
"name": "maxImageInBook",
"limit": 30,
"id": "59f2ef64d24efd45cbae5801",
"planFeatureId": "59f2ef64d24efd45cbae57da"
}
]
}
]
}
]
\ No newline at end of file
GET /api/Plans?filter={"include": {
"features": ["functionalities", "quotas"]}}
[
{
"name": "Basic",
"price": 100,
"defaultDuration": 0,
"id": "59f2ef64d24efd45cbae57d6",
"serviceId": "59f2ef64d24efd45cbae57c2",
"features": [
{
"name": "campaign",
"id": "59f2ef64d24efd45cbae57d8",
"featureId": "59f2ef64d24efd45cbae57c4",
"planId": "59f2ef64d24efd45cbae57d6",
"functionalities": [
{
"name": "removeCampaign",
"isAllowed": true,
"value": -1,
"id": "59f2ef64d24efd45cbae57e4",
"functionalityId": "59f2ef64d24efd45cbae57ca",
"planFeatureId": "59f2ef64d24efd45cbae57d8"
}
],
"quotas": [
{
"name": "maxCampaign",
"limit": 5,
"id": "59f2ef64d24efd45cbae57f5",
"planFeatureId": "59f2ef64d24efd45cbae57d8"
}
]
},
{
"name": "imageBook",
"id": "59f2ef64d24efd45cbae57da",
"featureId": "59f2ef64d24efd45cbae57c7",
"planId": "59f2ef64d24efd45cbae57d6",
"functionalities": [
{
"name": "addImageToBook",
"isAllowed": true,
"value": 1,
"id": "59f2ef64d24efd45cbae57e5",
"functionalityId": "59f2ef64d24efd45cbae57d3",
"planFeatureId": "59f2ef64d24efd45cbae57da"
},
{
"name": "removeImageFromBook",
"isAllowed": true,
"value": -1,
"id": "59f2ef64d24efd45cbae57e7",
"functionalityId": "59f2ef64d24efd45cbae57d0",
"planFeatureId": "59f2ef64d24efd45cbae57da"
}
],
"quotas": [
{
"name": "maxImageInBook",
"limit": 30,
"id": "59f2ef64d24efd45cbae5801",
"planFeatureId": "59f2ef64d24efd45cbae57da"
}
]
}
]
},
{
"name": "Limited",
"price": 0,
"defaultDuration": 0,
"id": "59f2ef64d24efd45cbae57d7",
"serviceId": "59f2ef64d24efd45cbae57c2",
"features": [
{
"name": "campaign",
"id": "59f2ef64d24efd45cbae57db",
"featureId": "59f2ef64d24efd45cbae57c4",
"planId": "59f2ef64d24efd45cbae57d7",
"functionalities": [
{
"name": "addCampaign",
"isAllowed": true,
"value": 1,
"id": "59f2ef64d24efd45cbae57ea",
"functionalityId": "59f2ef64d24efd45cbae57cb",
"planFeatureId": "59f2ef64d24efd45cbae57db"
}
],
"quotas": [
{
"name": "maxCampaign",
"limit": 1,
"id": "59f2ef64d24efd45cbae5800",
"planFeatureId": "59f2ef64d24efd45cbae57db"
}
]
},
{
"name": "imageBook",
"id": "59f2ef64d24efd45cbae57dc",
"featureId": "59f2ef64d24efd45cbae57c7",
"planId": "59f2ef64d24efd45cbae57d7",
"functionalities": [
{
"name": "removeImageFromBook",
"isAllowed": true,
"value": -1,
"id": "59f2ef64d24efd45cbae57ec",
"functionalityId": "59f2ef64d24efd45cbae57d0",
"planFeatureId": "59f2ef64d24efd45cbae57dc"
}
],
"quotas": [
{
"name": "maxImageInBook",
"limit": 5,
"id": "59f2ef64d24efd45cbae57fc",
"planFeatureId": "59f2ef64d24efd45cbae57dc"
}
]
}
]
}
]
\ No newline at end of file
GET /api/Services?filter={"include": [{
"features": "functionalities"}, "plans"]}
[
{
"name": "api",
"id": "59f2ef64d24efd45cbae57c2",
"features": [
{
"name": "campaignAlbum",
"isLimited": true,
"id": "59f2ef64d24efd45cbae57c3",
"serviceId": "59f2ef64d24efd45cbae57c2",
"functionalities": [
{
"name": "removeAlbumFromCampaign",
"isAvailable": true,
"isAllowedDefault": true,
"value": -1,
"id": "59f2ef64d24efd45cbae57cc",
"featureId": "59f2ef64d24efd45cbae57c3"
},
{
"name": "addAlbumToCampaign",
"isAvailable": true,
"isAllowedDefault": true,
"value": 1,
"id": "59f2ef64d24efd45cbae57cd",
"featureId": "59f2ef64d24efd45cbae57c3"
}
]
},
{
"name": "campaign",
"isLimited": true,
"id": "59f2ef64d24efd45cbae57c4",
"serviceId": "59f2ef64d24efd45cbae57c2",
"functionalities": [
{
"name": "removeCampaign",
"isAvailable": true,
"isAllowedDefault": true,
"value": -1,
"id": "59f2ef64d24efd45cbae57ca",
"featureId": "59f2ef64d24efd45cbae57c4"
},
{
"name": "addCampaign",
"isAvailable": true,
"isAllowedDefault": true,
"value": 1,
"id": "59f2ef64d24efd45cbae57cb",
"featureId": "59f2ef64d24efd45cbae57c4"
}
]
}
],
"plans": [
{
"name": "Basic",
"price": 100,