nytlabs / st-core

a data flow graphical programming language for data science
Apache License 2.0
37 stars 8 forks source link

API cleaning #213

Open nikhan opened 8 years ago

nikhan commented 8 years ago

API

GET /pattern Get JSON for all nodes.

POST /pattern Import JSON without a parent group. expects JSON body []CreateElement

GET /pattern?action=get&id=,,, (recursive) Batch JSON export of nodes.

POST /pattern?action=reset&id=,,, (recursive) Batch reset nodes.

POST /pattern?action=delete&id=,,, (recursive) Batch delete nodes.

POST /pattern?action=ungroup&id=,,, Batch ungroup nodes. Each group deleted and all child nodes are given to their grandparent.

POST /pattern?action=translate&x=<offset>&y=<offset>&id=,,, Batch translate nodes by offset.

GET /pattern/{id} Get JSON of id and all descendants of id.

POST /pattern/{id} Import JSON with parent group of id. expects JSON body []CreateElement

PUT /pattern/{id} sets node root keys. expects JSON body UpdateElement

GET /pattern/{id}/state returns node state (if applicable)

PUT /pattern/{id}/state sets node state (if applicable) expects JSON body

PUT /pattern/{id}/routes/{route_id} sets route state on a group (if applicable) expects JSON body UpdateElement

websocket client

subscription

{
    "action": "subscribe"
    "id": string
}

websocket server

element creation

{
    "action":"create"
    "data": [ Element ]
}

element translation

{
    "action":"translate"
    "x": int
    "y": int
    "data": [ ID ]
}

elements deleted

{
    "action":"delete"
    "data": [ ID ]
}

elements update alias

{
    "action":"update_alias"
    "id": string
    "alias": string
}

elements update position

{
    "action":"update_position"
    "id": string
    "position":{
        "x":int
        "y":int
    }
}

element update group route alias

{
    "action":"update_alias"
    "id": string
    "alias": string
}

element update group route hidden

{
    "action":"update_alias"
    "id": string
    "hidden": bool
}

element status

{
    "action":"status"
    "id": string
    "code": int
}

pattern JSON

[ Element... ] 

where element order is leaf-first

mikedewar commented 8 years ago

I don't quite understand:

nikhan commented 8 years ago

you POST an array of IDs -- this is for circumstances where you export a series of blocks without a root parent. I was thinking about offloading the operation that generates the copy JSON to the server, such that when you hit ctrl-c, it does this api call to recursively retrieve all JSON of selected blocks that does not require a root.

the second is if you want a store to have a specific value. so i can post my weights to a store or whatever.