Backend API

Actions

Scheme: actions.

GET
/api/actions
Getting a list of completed actions

Request

Request options:

Name In Type Description
where (Optional) url parameters JSON object Element filter. Used mongo query syntax.
sort (Optional) url parameters string Sorting items.
projection (Optional) url parameters JSON object Hiding fields.
embedded (Optional) url parameters JSON object Embedding items in fields.
page (Optional) url parameters integer Item page number.
max_results (Optional) url parameters integer Maximum number of items per page.

Request example:

curl -X GET http://tkcontrol/api/actions?sort=-_created&where={"action":"cmd.run"}

Response

Response example:

{
    "_items": [
        {
            "_id": "20200508145333792248medpc-6616cd.localdomain",
            "jid": "20200508145333792248",
            "action": "cmd.run",
            "host": "medpc-6616cd.localdomain",
            "state": "finished",
            "args": [
                {
                    "cmd": "ip a",
                    "__kwarg__": true
                 }
            ],
            "_updated": "Fri, 08 May 2020 11:59:12 GMT",
            "_created": "Fri, 08 May 2020 11:59:11 GMT",
            "return": "1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdis ...",
            "_links": {
                "self": {
                    "title": "Action",
                    "href": "actions/20200508145333792248medpc-6616cd.localdomain"
                },
                "related": {
                    "host": {
                        "title": "Host",
                        "href": "hosts/medpc-6616cd.localdomain"
                    }
                }
             }
         },
        {
            "_id": "20200508145312937405skupov-salt-minion-dev5",
            "jid": "20200508145312937405",
            "action": "cmd.run",
            "host": "skupov-salt-minion-dev5",
            "state": "finished",
            "args": [
                {
                    "cmd": "ip a",
                    "__kwarg__": true
                }
            ],
            "_updated": "Fri, 08 May 2020 11:58:51 GMT",
            "_created": "Fri, 08 May 2020 11:58:51 GMT",
            "return": "1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdis ...",
            "_links": {
               "self": {
                 "title": "Action",
                  "href": "actions/20200508145312937405skupov-salt-minion-dev5"
                },
                "related": {
                   "host": {
                       "title": "Host",
                       "href": "hosts/skupov-salt-minion-dev5"
                    }
                }
             }
        }
   ],
    "_links": {
        "parent": {
            "title": "home",
            "href": "/"
        },
        "self": {
          "title": "actions",
            "href": "actions?where={\"action\":\"cmd.run\"}&sort=-_created"
        }
    },
   "_meta": {
       "page": 1,
        "max_results": 25,
       "total": 2
    }
}
GET
/api/actions/{id}
Getting the completed action by id

Request

Request options:

Name In Type Description
projection (Optional) url parameters JSON object Hiding fields.
embedded (Optional) url parameters JSON object Embedding items in fields.

Request example:

curl -X GET http://tkcontrol/api/actions/20200508145312937405skupov-salt-minion-dev5

Response

Response example:

{
   "_id": "20200508145312937405skupov-salt-minion-dev5",
   "jid": "20200508145312937405",
    "action": "cmd.run",
    "host": "skupov-salt-minion-dev5",
    "state": "finished",
    "args": [
         {
            "cmd": "ip a",
            "__kwarg__": true
        }
     ],
    "_updated": "Fri, 08 May 2020 11:58:51 GMT",
    "_created": "Fri, 08 May 2020 11:58:51 GMT",
    "return": "1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdis ...",
    "_links": {
    "self": {
            "title": "Action",
            "href": "actions/20200508145312937405skupov-salt-minion-dev5"
        },
        "related": {
          "host": {
               "title": "Host",
                "href": "hosts/skupov-salt-minion-dev5"
            }
       },
        "parent": {
          "title": "home",
            "href": "/"
        },
        "collection": {
            "title": "actions",
            "href": "actions"
        }
    }
}

Aggregated host statistic

Scheme: hosts statistic.

GET
/api/hosts/statistics/online
Getting aggregated snapshots of the number of up and down hosts

Request

Request options:

Name In Type Description
where (Optional) url parameters JSON object Element filter. Used mongo aggregation syntax.
range (Optional) url parameters array Time period by which statistics are aggregated.
interval (Optional) url parameters integer Interval between the two closest shots.

Request example:

curl -X GET http://tkcontrol/api/hosts/statistics/online?range[]="Thu, 30 Apr 2020 17:43:25 GMT"&range[]="Fri, 01 May 2020 15:36:27 GMT"&where={"$eq":["$$host.key","accepted"]}&interval=500

Response

Response example:

[
    {
        "timestamp": "Thu, 30 Apr 2020 21:55:19 GMT",
        "_id": null,
        "hostnames": {
            "up": 4,
            "down": 6
        }
    },
    {
        "timestamp": "Fri, 01 May 2020 06:15:56 GMT",
        "_id": null,
        "hostnames": {
            "up": 4,
            "down": 6
        }
    },
    {
        "timestamp": "Fri, 01 May 2020 14:36:27 GMT",
        "_id": null,
        "hostnames": {
            "up": 4,
            "down": 6
        }
    },
]
GET
/api/hosts/statistics/unique_online
Getting list of hosts that were online (at least once) for selected time

Request

Request options:

Name In Type Description
where (Optional) url parameters JSON object Element filter. Used mongo aggregation syntax.
range (Optional) url parameters array Time period by which statistics are aggregated.

Request example:

curl -X GET http://tkcontrol/api/hosts/statistics/unique_online?range[]="Wed, 6 May 2020 15:12:00 GMT"&range[]="Thu, 7 May 2020 15:12:00 GMT"

Response

Response example:

[
   {
    "hostnames": {
            "up": [
                "skupov-salt-minion-dev5",
                "medpc-fe5f87.localdomain",
                "salt-master-staging",
                "medpc-6616cd.localdomain"
            ],
            "all": [
                "skupov-salt-minion-dev2",
                "skupov-salt-minion",
                "skupov-salt-minion-dev5",
                "medpc-grisha-test-salt-minion",
                "medpc-fe5f87.localdomain",
                "salt-master-staging",
                "salt-minion-staging-1",
                "medpc-6616cd.localdomain",
                "skupov-salt-minion-3-no-resp",
                "skupov-salt-unaccepted"
            ]
         }
    }
]
GET
/api/hosts/statistics/unique_updated
Getting list of hosts that have been updated (at least once) for selected time

Request

Request options:

Name In Type Description
where (Optional) url parameters JSON object Element filter. Used mongo aggregation syntax.
range (Optional) url parameters array Time period by which statistics are aggregated.

Request example:

curl -X GET http://tkcontrol/api/hosts/statistics/unique_updated?range[]="Wed, 6 May 2020 15:12:00 GMT"&range[]="Thu, 7 May 2020 15:12:00 GMT"

Response

Response example:

[
    {
        "hostnames": {
            "updated": [
                "skupov-salt-minion-dev2",
                "skupov-salt-minion"
            ],
            "all": [
                "skupov-salt-minion-dev5",
                "medpc-grisha-test-salt-minion",
                "medpc-fe5f87.localdomain",
                "salt-master-staging",
                "salt-minion-staging-1",
                "medpc-6616cd.localdomain",
                "skupov-salt-minion-3-no-resp",
                "skupov-salt-unaccepted"
            ]
        }
    }
]
GET
/api/hosts/statistics/unique_dist_upgraded
Getting list of hosts that have been dist-upgraded (at least once) in selected time

Request

Request options:

Name In Type Description
where (Optional) url parameters JSON object Element filter. Used mongo aggregation syntax.
range (Optional) url parameters array Time period by which statistics are aggregated.

Request example:

curl -X GET http://tkcontrol/api/hosts/statistics/unique_dist_upgraded?range[]="Wed, 6 May 2020 15:12:00 GMT"&range[]="Thu, 7 May 2020 15:12:00 GMT"

Response

Response example:

[
   {
        "hostnames": {
            "distUpgraded": [
                "skupov-salt-minion-dev2",
                "skupov-salt-minion"
            ],
            "all": [
                "skupov-salt-minion-dev5",
                "medpc-grisha-test-salt-minion",
                "medpc-fe5f87.localdomain",
                "salt-master-staging",
                "salt-minion-staging-1",
                "medpc-6616cd.localdomain",
                "skupov-salt-minion-3-no-resp",
                "skupov-salt-unaccepted"
            ]
        }
    }
 ]
GET
/api/hosts/statistics/new_hosts
Getting list of new hosts for selected time

Request

Request options:

Name In Type Description
where (Optional) url parameters JSON object Element filter. Used mongo aggregation syntax.
range (Optional) url parameters array Time period by which statistics are aggregated.

Request example:

curl -X GET http://tkcontrol/api/hosts/statistics/new_hosts?range[]="Wed, 6 May 2020 15:12:00 GMT"&range[]="Thu, 7 May 2020 15:12:00 GMT"

Response

Response example:

[
    {
        "hostnames": {
            "new": [
               "skupov-salt-minion-dev2",
                "skupov-salt-minion",
                "skupov-salt-minion-dev5",
                "medpc-grisha-test-salt-minion",
                "medpc-fe5f87.localdomain",
                "salt-master-staging",
                "salt-minion-staging-1",
                "medpc-6616cd.localdomain",
                "skupov-salt-minion-3-no-resp",
                "skupov-salt-unaccepted"
            ]
        }
    }
]

Alerts

Scheme: alerts.

GET
/api/alerts
Getting list of notifications

Request

Request options:

Name In Type Description
mark_as_read (Optional) url parameters integer If flag is set to 1, then replaces the field ‘read’ to true.
where (Optional) url parameters JSON object Element filter. Used mongo query syntax.
sort (Optional) url parameters string Sorting items.
projection (Optional) url parameters JSON object Hiding fields.
embedded (Optional) url parameters JSON object Embedding items in fields.
page (Optional) url parameters integer Item page number.
max_results (Optional) url parameters integer Maximum number of items per page.

Request example:

curl -X GET http://tkcontrol/api/alerts

Response

Response example:

{
    "_items": [
        {
            "_id": "5fbe0586114dbae05878a102",
            "type": "vnc.connect",
            "level": "info",
            "payload": {
                "hostname": "medpc-3b6547.localdomain",
                "status": "connected"
            },
            "read": true,
            "_updated": "Fri, 18 Dec 2020 08:11:41 GMT",
            "_created": "Wed, 25 Nov 2020 07:19:34 GMT",
            "_links": {
                "self": {
                    "title": "Alert",
                    "href": "alerts/5fbe0586114dbae05878a102"
                }
            }
        },
        {
            "_id": "5fbe04fd114dbae05878a0ff",
            "type": "vnc.connect",
            "level": "info",
            "payload": {
                "hostname": "medpc-3b6547.localdomain",
                "status": "connected"
            },
            "read": true,
            "_updated": "Fri, 18 Dec 2020 08:11:41 GMT",
            "_created": "Wed, 25 Nov 2020 07:17:17 GMT",
            "_links": {
                "self": {
                    "title": "Alert",
                    "href": "alerts/5fbe04fd114dbae05878a0ff"
                }
            }
        },
        {
            "_id": "5fb25e4f1e19e5a414df3533",
            "type": "vnc.connect",
            "level": "info",
            "payload": {
                "hostname": "medpc-3b6547.localdomain",
                "status": "connected"
            },
            "read": true,
            "_updated": "Fri, 18 Dec 2020 08:11:41 GMT",
            "_created": "Mon, 16 Nov 2020 11:11:11 GMT",
            "_links": {
                "self": {
                    "title": "Alert",
                    "href": "alerts/5fb25e4f1e19e5a414df3533"
                }
            }
        }
    ],
    "_links": {
        "parent": {
            "title": "home",
            "href": "/"
        },
        "self": {
            "title": "alerts",
            "href": "alerts?max_results=3&sort=-_created&mark_as_read=1"
        },
        "next": {
            "title": "next page",
            "href": "alerts?max_results=3&sort=-_created&page=2&mark_as_read=1"
        },
        "last": {
            "title": "last page",
            "href": "alerts?max_results=3&sort=-_created&page=19&mark_as_read=1"
        }
    },
    "_meta": {
        "page": 1,
        "max_results": 3,
        "total": 56
    }
}
GET
/api/alerts/{id}
Getting notification by ID

Request

Request options:

Name In Type Description
mark_as_read (Optional) url parameters integer If flag is set to 1, then replaces the field ‘read’ to true.
projection (Optional) url parameters JSON object Hiding fields.
embedded (Optional) url parameters JSON object Embedding items in fields.

Request example:

curl -X GET http://tkcontrol/api/alerts/5fb25e4f1e19e5a414df3533

Response

Response example:

{
    "_id": "5fb25e4f1e19e5a414df3533",
    "type": "vnc.connect",
    "level": "info",
    "payload": {
        "hostname": "medpc-3b6547.localdomain",
        "status": "connected"
    },
    "read": true,
    "_updated": "Fri, 18 Dec 2020 08:11:55 GMT",
    "_created": "Mon, 16 Nov 2020 11:11:11 GMT",
    "_links": {
        "self": {
            "title": "Alert",
            "href": "alerts/5fb25e4f1e19e5a414df3533"
        },
        "parent": {
            "title": "home",
            "href": "/"
        },
        "collection": {
            "title": "alerts",
            "href": "alerts"
        }
    }
}

Failed patches

Scheme: failed patches.

GET
/api/failed_patches
Getting list of badly applied patches

Request

Request options:

Name In Type Description
where (Optional) url parameters JSON object Element filter. Used mongo query syntax.
sort (Optional) url parameters string Sorting items.
projection (Optional) url parameters JSON object Hiding fields.
embedded (Optional) url parameters JSON object Embedding items in fields.
page (Optional) url parameters integer Item page number.
max_results (Optional) url parameters integer Maximum number of items per page.

Request example:

curl -X GET http://tkcontrol/api/failed_patches

Response

Response example:

{
    "_items": [
        {
            "_id": "20200415130343688447skupov-salt-minion-dev5",
            "jid": "20200415130343688447",
            "action": "state.apply",
            "host": "skupov-salt-minion-dev5",
            "state": "finished",
            "return": [
               {
                    "comment": "Command ...",
                    "name": "cd ..",
                    "start_time": "10:07:39.546415",
                    "result": true,
                    "duration": 34.073,
                    "__run_num__": 0,
                    "__sls__": "patch-6",
                    "changes": {
                        "pid": 8255,
                        "retcode": 0,
                        "stderr": "--2020-04-15 10:07:39--  \nHTTP request sent, awaiting response...",
                        "stdout": ""
                    },
                    "__id__": "patch-6.1",
                    "cmd": "cmd_|-patch-6.1_|-cd ..."
                },
                {
                    "comment": "Command ...",
                    "name": "chmod ...",
                    "start_time": "10:07:39.580873",
                    "result": true,
                    "duration": 15.235,
                    "__run_num__": 1,
                    "__sls__": "patch-6",
                    "changes": {
                        "pid": 8257,
                        "retcode": 0,
                        "stderr": "",
                        "stdout": ""
                    },
                    "__id__": "patch-6.2",
                    "cmd": "cmd_|-patch-6.2_|-chmod ..."
                },
                {
                   "comment": "Command ...",
                    "name": "mv ...",
                    "start_time": "10:07:39.596415",
                    "result": true,
                    "duration": 7.141,
                    "__run_num__": 2,
                    "__sls__": "patch-6",
                    "changes": {
                        "pid": 8259,
                        "retcode": 0,
                        "stderr": "",
                        "stdout": ""
                    },
                    "__id__": "patch-6.3",
                    "cmd": "cmd_|-patch-6.3_|-mv ..."
                },
                {
                    "comment": "Command ...",
                    "name": "mv ...",
                    "start_time": "10:07:39.603876",
                    "result": false,
                    "duration": 9.18,
                    "__run_num__": 3,
                    "__sls__": "patch-6",
                    "changes": {
                        "pid": 8261,
                        "retcode": 2,
                        "stderr": "sed: can't read ...",
                        "stdout": ""
                   },
                    "__id__": "patch-6.4",
                    "cmd": "cmd_|-patch-6.4_|-sed ..."
                }
            ],
            "patch": "patch-6",
            "_updated": "Wed, 15 Apr 2020 10:07:29 GMT",
            "_created": "Wed, 15 Apr 2020 10:07:29 GMT",
            "_links": {
                "self": {
                    "title": "Failed_patche",
                    "href": "failed_patches/20200415130343688447skupov-salt-minion-dev5"
                },
                "related": {
                    "host": {
                        "title": "Host",
                        "href": "hosts/skupov-salt-minion-dev5"
                    }
                }
            }
        },
    ],
    "_links": {
        "parent": {
            "title": "home",
            "href": "/"
        },
        "self": {
            "title": "failed_patches",
           "href": "failed_patches"
        }
    },
    "_meta": {
        "page": 1,
        "max_results": 25,
        "total": 7
    }
}
GET
/api/failed_patches/{id}
Getting unsuccessfully applied patch by id

Request

Request options:

Name In Type Description
projection (Optional) url parameters JSON object Hiding fields.
embedded (Optional) url parameters JSON object Embedding items in fields.

Request example:

curl -X GET http://tkcontrol/api/failed_patches/20200415130343688447skupov-salt-minion-dev5

Response

Response example:

{
"_id": "20200415130343688447skupov-salt-minion-dev5",
"jid": "20200415130343688447",
"action": "state.apply",
    "host": "skupov-salt-minion-dev5",
    "state": "finished",
    "return": [
       {
            "comment": "Command ...",
            "name": "cd ..",
            "start_time": "10:07:39.546415",
            "result": true,
            "duration": 34.073,
            "__run_num__": 0,
            "__sls__": "patch-6",
            "changes": {
                "pid": 8255,
                "retcode": 0,
                "stderr": "--2020-04-15 10:07:39--  \nHTTP request sent, awaiting response...",
                "stdout": ""
            },
            "__id__": "patch-6.1",
            "cmd": "cmd_|-patch-6.1_|-cd ..."
        },
        {
            "comment": "Command ...",
            "name": "chmod ...",
            "start_time": "10:07:39.580873",
            "result": true,
            "duration": 15.235,
            "__run_num__": 1,
            "__sls__": "patch-6",
            "changes": {
                "pid": 8257,
                "retcode": 0,
                "stderr": "",
                "stdout": ""
            },
            "__id__": "patch-6.2",
            "cmd": "cmd_|-patch-6.2_|-chmod ..."
        },
        {
            "comment": "Command ...",
            "name": "mv ...",
            "start_time": "10:07:39.596415",
            "result": true,
            "duration": 7.141,
            "__run_num__": 2,
            "__sls__": "patch-6",
            "changes":
                "pid": 8259,
                "retcode": 0,
                "stderr": "",
                "stdout": ""
            },
            "__id__": "patch-6.3",
            "cmd": "cmd_|-patch-6.3_|-mv ..."
        },
        {
            "comment": "Command ...",
            "name": "mv ...",
            "start_time": "10:07:39.603876",
            "result": false,
            "duration": 9.18,
            "__run_num__": 3,
            "__sls__": "patch-6",
            "changes": {
                "pid": 8261,
                "retcode": 2,
                "stderr": "sed: can't read ...",
                "stdout": ""
            },
            "__id__": "patch-6.4",
            "cmd": "cmd_|-patch-6.4_|-sed ..."
        }
    ],
    "patch": "patch-6",
    "_updated": "Wed, 15 Apr 2020 10:07:29 GMT",
    "_created": "Wed, 15 Apr 2020 10:07:29 GMT",
    "_links": {
        "self": {
            "title": "Failed_patche",
            "href": "failed_patches/20200415130343688447skupov-salt-minion-dev5"
        },
        "related": {
            "host": {
                "title": "Host",
                "href": "hosts/skupov-salt-minion-dev5"
            }
        }
    }
}

Files

Scheme: files.

GET
/api/files
Getting list of files

Request

Request options:

Name In Type Description
where (Optional) url parameters JSON object Element filter. Used mongo query syntax.
sort (Optional) url parameters string Sorting items.
projection (Optional) url parameters JSON object Hiding fields.
embedded (Optional) url parameters JSON object Embedding items in fields.
page (Optional) url parameters integer Item page number.
max_results (Optional) url parameters integer Maximum number of items per page.

Request example:

curl -X GET http://tkcontrol/api/files

Response

Response example:

{
    "_items": [
        {
            "_id": "5f73049d836e90817cbccaab",
            "data": "/api/media/5f73049d836e90817cbccaa9",
            "name": "addresses.xlsx",
            "_updated": "Tue, 29 Sep 2020 09:55:41 GMT",
            "_created": "Tue, 29 Sep 2020 09:55:41 GMT",
            "_links": {
                "self": {
                    "title": "File",
                    "href": "files/5f73049d836e90817cbccaab"
                }
            }
        }
    ],
    "_links": {
        "parent": {
            "title": "home",
            "href": "/"
        },
        "self": {
            "title": "files",
            "href": "files"
        }
    },
    "_meta": {
        "page": 1,
        "max_results": 25,
        "total": 1
    }
}
GET
/api/files/{id}
Getting file by id

Request

Request options:

Name In Type Description
projection (Optional) url parameters JSON object Hiding fields.
embedded (Optional) url parameters JSON object Embedding items in fields.

Request example:

curl -X GET http://tkcontrol/api/files/5f73049d836e90817cbccaab

Response

Response example:

{
    "_id": "5f73049d836e90817cbccaab",
    "data": "/api/media/5f73049d836e90817cbccaa9",
    "name": "addresses.xlsx",
    "_updated": "Tue, 29 Sep 2020 09:55:41 GMT",
    "_created": "Tue, 29 Sep 2020 09:55:41 GMT",
    "_links": {
        "self": {
            "title": "File",
            "href": "files/5f73049d836e90817cbccaab"
        },
        "parent": {
            "title": "home",
            "href": "/"
        },
        "collection": {
            "title": "files",
            "href": "files"
        }
    }
}
POST
/api/files
Save new file

Save new file.

Request

Request options:

Name In Type Description
name (Optional) body string File name.
data (Optional) body binary File data.

Request example:

curl -X POST http://tkcontrol/api/files -d '\
    data: (binary) \
    name: addresses.xlsx \
'

Graph

GET
api/graph/{id}
Getting graph, where the root is the group with given id

Request

Request example:

curl -X GET http://tkcontrol/api/graph/5ea2da1910b639cdfe83bb3f

Response

Response example:

{
    "nodes": [
        {
            "category": "group",
            "type": 1,
            "id": "5eb51ee46b1229b259e8f39a",
            "name": "linux",
            "info": {
                "grain": {
                    "kernel": "Linux"
                }
            },
            "value": 1,
            "itemStyle": {
                "color": "#e57373"
            },
            "symbolSize": 10
        },
        {
            "category": "group",
            "type": 1,
            "id": "5eb51ee46b1229b259e8f39a",
            "name": "linux",
            "info": {
                "grain": {
                    "kernel": "Linux"
                }
           },
            "value": 1,
            "itemStyle": {
                "color": "#e57373"
            },
            "symbolSize": 10
        },
        {
            "category": "group",
            "type": 1,
            "id": "5eb51ee410703b151657d15d",
            "name": "skupov-img",
            "info": {
                "regex": "skupov.*"
            },
            "value": 1,
            "itemStyle": {
                "color": "#e57373"
            },
            "symbolSize": 10
        },
        {
            "category": "group",
            "type": 0,
            "id": "5eb52478f0e593e6ec94f3ab",
            "name": "web servers",
            "info": {},
            "value": 0,
            "itemStyle": {
                "color": "#AED581"
            },
            "symbolSize": 0
        },
        {
            "category": "group",
            "type": 0,
            "id": "5eb52132f0e593e6ec94f3aa",
            "name": "subgroup_med",
            "info": {},
            "value": 0,
            "itemStyle": {
                "color": "#AED581"
            },
            "symbolSize": 0
        },
        {
            "category": "group",
            "type": 0,
            "id": "5ea2da1910b639cdfe83bb3f",
            "name": "medka",
            "info": {},
            "value": 0,
            "itemStyle": {
                "color": "#AED581"
            },
            "symbolSize": 0
        }
    ],
    "edges": [
        {
            "type": "groupLink",
            "source": "5eb52478f0e593e6ec94f3ab",
            "target": "5eb51ee46b1229b259e8f39a"
       },
        {
            "type": "groupLink",
            "source": "5eb52478f0e593e6ec94f3ab",
            "target": "5eb51ee410703b151657d15d"
        },
        {
            "type": "groupLink",
            "source": "5eb52132f0e593e6ec94f3aa",
            "target": "5eb51ee46b1229b259e8f39a"
        },
        {
            "type": "groupLink",
            "source": "5eb52132f0e593e6ec94f3aa",
            "target": "5eb52478f0e593e6ec94f3ab"
        },
        {
            "type": "groupLink",
            "source": "5ea2da1910b639cdfe83bb3f",
            "target": "5eb52132f0e593e6ec94f3aa"
        }
    ]
}
GET
/api/graph/{id}/nodes
Getting only nodes of the graph, where the root is the group with given id

Request

Request options:

Name In Type Description
where (Optional) url parameters JSON object Node filter. Accepts a ‘type’ argument of type ‘integer’.

Request example:

curl -X GET http://tkcontrol/api/graph/5ea2da1910b639cdfe83bb3f/nodes

Response

Response example:

{
   "nodes": [
        {
            "category": "group",
            "type": 1,
            "id": "5eb51ee46b1229b259e8f39a",
            "name": "linux",
            "info": {
                "grain": {
                    "kernel": "Linux"
                }
            },
            "value": 1,
            "itemStyle": {
                "color": "#e57373"
            },
           "symbolSize": 10
        },
        {
            "category": "group",
            "type": 1,
            "id": "5eb51ee46b1229b259e8f39a",
            "name": "linux",
            "info": {
                "grain": {
                   "kernel": "Linux"
               }
            },
            "value": 1,
            "itemStyle": {
                "color": "#e57373"
            },
            "symbolSize": 10
        },
        {
            "category": "group",
            "type": 1,
            "id": "5eb51ee410703b151657d15d",
            "name": "skupov-img",
            "info": {
            "regex": "skupov.*"
            },
            "value": 1,
            "itemStyle": {
                "color": "#e57373"
            },
            "symbolSize": 10
        },
        {
            "category": "group",
            "type": 0,
            "id": "5eb52478f0e593e6ec94f3ab",
            "name": "web servers",
            "info": {},
            "value": 0,
            "itemStyle": {
                "color": "#AED581"
            },
            "symbolSize": 0
        },
        {
            "category": "group",
            "type": 0,
            "id": "5eb52132f0e593e6ec94f3aa",
            "name": "subgroup_med",
            "info": {},
            "value": 0,
            "itemStyle": {
                "color": "#AED581"
            },
            "symbolSize": 0
        },
        {
            "category": "group",
            "type": 0,
            "id": "5ea2da1910b639cdfe83bb3f",
            "name": "medka",
            "info": {},
            "value": 0,
            "itemStyle": {
                "color": "#AED581"
            },
            "symbolSize": 0
        }
    ]
}
GET
/api/graph/{id}/edges
Getting only links of the graph, where the root is the group with given id

Request example:

curl -X GET http://tkcontrol/api/graph/5ea2da1910b639cdfe83bb3f/edges

Response

Response example:

{
    "edges": [
        {
            "type": "groupLink",
            "source": "5eb52478f0e593e6ec94f3ab",
            "target": "5eb51ee46b1229b259e8f39a"
        },
        {
            "type": "groupLink",
            "source": "5eb52478f0e593e6ec94f3ab",
            "target": "5eb51ee410703b151657d15d"
        },
        {
            "type": "groupLink",
            "source": "5eb52132f0e593e6ec94f3aa",
            "target": "5eb51ee46b1229b259e8f39a"
        },
        {
            "type": "groupLink",
            "source": "5eb52132f0e593e6ec94f3aa",
            "target": "5eb52478f0e593e6ec94f3ab"
        },
        {
            "type": "groupLink",
            "source": "5ea2da1910b639cdfe83bb3f",
            "target": "5eb52132f0e593e6ec94f3aa"
        }
    ]
}
GET
/api/graph/not-linked
Getting unattached gateways

Request

Request example:

curl -X GET http://tkcontrol/
POST
/api/graph
Perform action on the graph handler

Request

Request options:

Name In Type Description
action (Optional) body string Action to be performed on the graph. Possible actions are ‘request_ips’, ‘build_graph’.”
ip_resolver (Optional) body string URL address ip resolver. Used with action ‘request_ips’ only.
master (Optional) body string Master server name. Used with action ‘build_graph’ only.

Request example:

curl -X POST http://tkcontrol/api/graph -H "Content-Type: application/json" -d '{ \
    "action": "request_ips", \
    "ip_resolver": "http://master/resolve" \
}'
curl -X POST http://tkcontrol/api/graph  -H "Content-Type: application/json" -d '{ \
    "action": "build_graph", \
    "master": "config.dev" \
}'

Groups

Scheme: groups.

GET
/api/groups
Getting list of groups

Request

Request options:

Name In Type Description
where (Optional) url parameters JSON object Element filter. Used mongo query syntax.
sort (Optional) url parameters string Sorting items.
projection (Optional) url parameters JSON object Hiding fields.
embedded (Optional) url parameters JSON object Embedding items in fields.
page (Optional) url parameters integer Item page number.
max_results (Optional) url parameters integer Maximum number of items per page.

Request example:

curl -X GET http://tkcontrol/api/groups

Response

Response example:

{
   "_items": [
        {
            "_id": "5ea2da1910b639cdfe83bb3f",
            "name": "medka",
            "subgroups": [
                "5eb52132f0e593e6ec94f3aa"
            ],
            "type": 0,
            "_updated": "Fri, 08 May 2020 09:07:54 GMT",
            "_created": "Fri, 24 Apr 2020 12:22:49 GMT",
            "_links": {
                "self": {
                    "title": "Group",
                    "href": "groups/5ea2da1910b639cdfe83bb3f"
                },
                "related": {
                    "subgroups": [
                        {
                            "title": "Group",
                            "href": "groups/5eb52132f0e593e6ec94f3aa"
                        }
                    ]
                }
            }
        },
        {
            "_id": "5eb51ee46b1229b259e8f399",
            "name": "medpc-img",
            "type": 1,
            "info": {
                "regex": "medpc-.*",
                "grain": {
                    "osfullname": "ALT",
                    "cpuarch": "x86_64"
                }
            },
            "_updated": "Fri, 08 May 2020 08:57:08 GMT",
            "_created": "Fri, 08 May 2020 08:57:08 GMT",
            "_links": {
                "self": {
                    "title": "Group",
                    "href": "groups/5eb51ee46b1229b259e8f399"
                }
            }
        },
        {
            "_id": "5eb51ee410703b151657d15d",
            "name": "skupov-img",
            "type": 1,
            "info": {
                "regex": "skupov.*"
             },
             "_updated": "Fri, 08 May 2020 08:57:08 GMT",
             "_created": "Fri, 08 May 2020 08:57:08 GMT",
             "_links": {
                 "self": {
                     "title": "Group",
                     "href": "groups/5eb51ee410703b151657d15d"
                 }
             }
         },
         {
             "_id": "5eb52132f0e593e6ec94f3aa",
             "name": "subgroup_med",
             "subgroups": [],
             "type": 0,
             "_updated": "Fri, 08 May 2020 09:08:32 GMT",
             "_created": "Fri, 08 May 2020 09:06:58 GMT",
             "_links": {
                "self": {
                   "title": "Group",
                    "href": "groups/5eb52132f0e593e6ec94f3aa"
                 },
                 "related": {
                     "subgroups": []
                 }
            }
         }
    ],
    "_links": {
        "parent": {
           "title": "home",
            "href": "/"
        },
            "self": {
            "title": "groups",
             "href": "groups"
        }
    },
    "_meta": {
        "page": 1,
        "max_results": 25,
        "total": 4
    }
}
GET
/api/groups/{id}
Getting group by id

Request

Request options:

Name In Type Description
projection (Optional) url parameters JSON object Hiding fields.
embedded (Optional) url parameters JSON object Embedding items in fields.

Request example:

curl -X GET http://tkcontrol/api/groups/5ea2da1910b639cdfe83bb3f?embedded={"subgroups":1}

Response

Response example:

{
    "_id": "5ea2da1910b639cdfe83bb3f",
    "name": "medka",
    "subgroups": [
        {
            "_id": "5eb52132f0e593e6ec94f3aa",
            "name": "subgroup_med",
            "subgroups": [],
            "type": 0,
            "_updated": "Fri, 08 May 2020 09:08:32 GMT",
            "_created": "Fri, 08 May 2020 09:06:58 GMT"
        }
    ],
    "type": 0,
    "_updated": "Fri, 08 May 2020 09:07:54 GMT",
    "_created": "Fri, 24 Apr 2020 12:22:49 GMT",
    "_links": {
        "self": {
            "title": "Group",
            "href": "groups/5ea2da1910b639cdfe83bb3f"
        },
        "related": {
            "subgroups": [
                {
                    "title": "Group",
                    "href": "groups/5eb52132f0e593e6ec94f3aa"
                }
           ]
        },
        "parent": {
            "title": "home",
            "href": "/"
        },
        "collection": {
           "title": "groups",
           "href": "groups"
        }
    }
}
GET
/api/groups/{id}/subgroups
Getting subgroups of group by its id

Request

Request example:

curl -X GET http://tkcontrol/api/groups/5ea2da1910b639cdfe83bb3f/subgroups

Response

Response example:

[
    "5eb52132f0e593e6ec94f3aa"
]
GET
/api/groups/{id}/hostnames
Getting hostnames belonging to group and all nested subgroups of that group

Request

Request example:

curl -X GET http://tkcontrol/api/groups/5ea2da1910b639cdfe83bb3f/hostnames

Response

Response example:

[
    "skupov-salt-minion-dev2",
    "medpc-fe5f87.localdomain",
    "salt-master-staging",
    "salt-minion-staging-1",
    "skupov-salt-minion-3-no-resp",
    "skupov-salt-unaccepted"
]
POST
api/groups
Creating new group

Request example:

curl -X POST http://tkcontrol/api/groups -H "Content-Type: application/json" -d '{ \
     { \
         "name": "web servers", \
         "subgroups": [ \
             "5eb51ee46b1229b259e8f39a" \
          ], \
          "hosts": [ \
             "salt-minion-staging-1", \
             "salt-master-staging" \
         ], \
         "type": 0 \
     }'

Response

Response example:

{
    "_updated": "Thu, 17 Dec 2020 14:13:12 GMT",
    "_created": "Thu, 17 Dec 2020 14:13:12 GMT",
    "_id": "5fdb677898305492eb558ccf",
    "_links": {
        "self": {
            "title": "Group",
            "href": "groups/5fdb677898305492eb558ccf"
        },
        "related": {
            "subgroups": []
         }
     },
    "_status": "OK"
 }
POST
/api/groups/{id}
Performing an action on group

Request

Request options:

This endpoint is a proxy POST request to http://salt-api/. But parameter “salt_client” is replaced by “client”, “tgt” sets to an array of hosts that belong to this group, and “tgt_type” to “list”. You can read about all possible functions at the Salt Module Reference.

Request example:

curl -X POST http://tkcontrol/api/groups/5eb51ee46b1229b259e8f399 -H "Content-Type: application/json" -d '{ \
     { \
         "salt_client": "local", \
         "fun": "cmd.run", \
         "kwarg": { \
             "cmd": "date" \
         } \
     }'

Response

Response example:

{
    "task_id":"603e3c733f97526801fd3176",
    "status":"success",
    "return":{
        "return":[
            {
                "skupov-staging-tkcontrol-non-root-client1":"Tue Mar  2 13:24:04 UTC 2021"
            }
        ]
    }
}
PATCH
/api/groups/{id}
Changing group by id

Request

Request example:

curl -X PATCH http://tkcontrol/api/groups/5ea2da1910b639cdfe83bb3f -H "Content-Type: application/json" -d '{ \
     { \
         "hosts": [ \
             "medpc-fe5f87.localdomain", \
             "salt-master-staging" \
         ] \
     }'

Response

Response example:

{
    "_id": "5ea2da1910b639cdfe83bb3f",
    "_updated": "Thu, 17 Dec 2020 14:18:50 GMT",
    "_created": "Thu, 17 Dec 2020 14:12:57 GMT",
    "_links": {
        "self": {
            "title": "Group",
            "href": "groups/5ea2da1910b639cdfe83bb3f/5ea2da1910b639cdfe83bb3f"
        },
        "related": {
            "subgroups": [
                {
                    "title": "Group",
                    "href": "groups/5ea2da1910b639cdfe83bb3f/5f73088a7594a4ab6be8cef7"
                }
            ]
        }
    },
    "_status": "OK"
}
DELETE
/api/groups
Deleting groups of specific type

Request

Request options:

Name In Type Description
where (Optional) url parameters JSON object Group filter. It accepts ‘type’ argument of type ‘array of integers’ or ‘integer’.

Request example:

curl -X DELETE http://tkcontrol/api/groups?where={"type":[2,3,4]}
DELETE
/api/groups/{id}
Deleting group by id

Request

Request example:

curl -X DELETE http://tkcontrol/api/groups/5ea2da1910b639cdfe83bb3f

Hosts

Scheme: hosts.

GET
/api/hosts
Getting list of groups

Request

Request options:

Name In Type Description
where (Optional) url parameters JSON object Element filter. Used mongo query syntax.
sort (Optional) url parameters string Sorting items.
projection (Optional) url parameters JSON object Hiding fields.
embedded (Optional) url parameters JSON object Embedding items in fields.
page (Optional) url parameters integer Item page number.
max_results (Optional) url parameters integer Maximum number of items per page.
show_soft_deleted (Optional) url parameters bool Show soft deleted.

Request example:

curl -X GET http://tkcontrol/api/hosts?where={"key":"accepted","status":"up"}&projection={"grain":0}

Response

Response example:

{
    "_items": [
        {
            "_id": "medpc-271e56.localdomain",
            "version": "28",
            "ip": "10.10.19.248",
            "nodegroups": [
                "medpc-img",
                "linux"
            ],
            "last_distupgrade": "Thu, 26 Mar 2020 15:22:16 GMT",
            "last_stateapply": "Wed, 11 Nov 2020 10:09:22 GMT",
            "_soft_deleted": false,
            "status": "up",
            "_updated": "Wed, 16 Dec 2020 09:23:26 GMT",
            "_created": "Fri, 25 Sep 2020 12:26:25 GMT",
            "heartbeat": "Wed, 11 Nov 2020 12:08:15 GMT",
            "key": "accepted",
            "last_action": "20201111130724122307medpc-271e56.localdomain",
            "groups": [
                "5f8da6501eb86343459e26ce"
            ],
            "nat": false,
            "fingerprint": "66:52:5d:4f:8d:d0:a3:4a:e0:25:50:a3:d3:f1:b7:49:de:d2:fe:5d:36:16:50:cd:5b:29:bd:a2:91:bd:5f:0a",
            "fingerprint_history": [
                {
                   "added": "Tue, 03 Nov 2020 07:40:58 GMT",
                   "fingerprint": "66:52:5d:4f:8d:d0:a3:4a:e0:25:50:a3:d3:f1:b7:49:de:d2:fe:5d:36:16:50:cd:5b:29:bd:a2:91:bd:5f:0a"
                }
            ],
            "pritunl_representation": {
                "auth_type": "local",
                "yubico_id": null,
                "client_to_client": false,
                "otp_secret": "Q6SQ6Q72XKLD7GMI",
                "name": "medpc-271e56.localdomain",
                "pin": false,
                "dns_suffix": null,
                "disabled": false,
                "mac_addresses": null,
                "email": "",
                "organization_name": "rsa-org-test",
                "bypass_secondary": false,
                "groups": [],
                "organization": "5fa001d043e2108e8ffb7a6d",
                "port_forwarding": [],
                "dns_servers": null,
                "type": "client",
                "id": "5fa001d143e2108e8ffb7a74"
            },
            "vpn_organization": "5fa10a25ccb8d1bdb79feeeb",
            "identification_number": "fdf",
            "_links": {
                "self": {
                    "title": "Host",
                    "href": "hosts/medpc-271e56.localdomain"
                },
                "related": {
                    "last_action": {
                        "title": "Action",
                        "href": "actions/20201111130724122307medpc-271e56.localdomain"
                    },
                    "groups": [
                        {
                            "title": "Group",
                            "href": "groups/5f8da6501eb86343459e26ce"
                        }
                    ],
                    "nodegroups": [
                        {
                            "title": "Nodegroup",
                            "href": "nodegroups/medpc-img"
                        },
                        {
                            "title": "Nodegroup",
                            "href": "nodegroups/linux"
                        }
                   ],
                   "vpn_organization": {
                        "title": "Vpn_organization",
                        "href": "vpn_organizations/5fa10a25ccb8d1bdb79feeeb"
                    }
                }
            }
        }
    ],
    "_links": {
        "parent": {
            "title": "home",
            "href": "/"
        },
        "self": {
            "title": "hosts",
            "href": "hosts?where={\"key\":\"accepted\",\"status\":\"up\"}"
        }
    },
    "_meta": {
        "page": 1,
        "max_results": 25,
        "total": 1
    }
}
GET
/api/hosts/{id}
Getting host by id

Request

Request options:

Name In Type Description
projection (Optional) url parameters JSON object Hiding fields.
embedded (Optional) url parameters JSON object Embedding items in fields.
show_soft_deleted (Optional) url parameters bool Show soft deleted.

Request example:

curl -X GET http://tkcontrol/api/hosts/medpc-271e56.localdomain

Response

Response example:

{
    "_id": "medpc-271e56.localdomain",
    "version": "28",
    "ip": "10.10.19.248",
    "nodegroups": [
        "medpc-img",
        "linux"
    ],
    "grain": {
        "cpu_model": "Intel Xeon E312xx (Sandy Bridge)",
        "cpuarch": "x86_64",
        "mem_total": 1987,
        "num_cpus": 2,
        "num_gpus": 1,
        "virtual": "kvm",
        "gpus": [
           {
                "model": "Device 1111",
                "vendor": "unknown"
            }
       ],
        "serialnumber": null,
        "biosversion": null,
        "saltversion": "2017.7.0",
        "tk-version": 28,
        "tkcontrol": {
           "last_distupgrade": "2020-03-26 15:22:16+00:00",
           "last_stateapply": "2020-11-10 09:47:01+00:00"
        },
        "kernel": "Linux",
        "kernelrelease": "4.19.59-un-def-alt0.M80C.1",
        "lsb_distrib_id": "ALT",
        "osfullname": "ALT",
        "lsb_distrib_description": null,
        "host": "localhost",
        "domain": "localdomain",
        "localhost": "medpc-271e56.localdomain",
        "ip_interfaces": {
           "lo": [
                "127.0.0.1",
                "::1"
            ],
            "ens3": [
                "10.10.19.29",
                "fe80::dd9d:6e76:e4a9:48c2"
            ],
            "ens18": [
                "10.10.19.248",
                "fe80::ba9d:5fb:9f5f:86fa"
            ]
        },
        "ip": "10.10.19.248",
    },
    "last_distupgrade": "Thu, 26 Mar 2020 15:22:16 GMT",
    "last_stateapply": "Wed, 11 Nov 2020 10:09:22 GMT",
    "_soft_deleted": false,
    "status": "up",
    "_updated": "Wed, 16 Dec 2020 09:23:26 GMT",
    "_created": "Fri, 25 Sep 2020 12:26:25 GMT",
    "heartbeat": "Wed, 11 Nov 2020 12:08:15 GMT",
    "key": "accepted",
    "last_action": "20201111130724122307medpc-271e56.localdomain",
    "groups": [
        "5f8da6501eb86343459e26ce"
    ],
    "nat": false,
    "fingerprint": "66:52:5d:4f:8d:d0:a3:4a:e0:25:50:a3:d3:f1:b7:49:de:d2:fe:5d:36:16:50:cd:5b:29:bd:a2:91:bd:5f:0a",
    "fingerprint_history": [
       {
            "added": "Tue, 03 Nov 2020 07:40:58 GMT",
            "fingerprint": "66:52:5d:4f:8d:d0:a3:4a:e0:25:50:a3:d3:f1:b7:49:de:d2:fe:5d:36:16:50:cd:5b:29:bd:a2:91:bd:5f:0a"
       }
    ],
    "pritunl_representation": {
        "auth_type": "local",
        "yubico_id": null,
        "client_to_client": false,
        "otp_secret": "Q6SQ6Q72XKLD7GMI",
        "name": "medpc-271e56.localdomain",
        "pin": false,
        "dns_suffix": null,
        "disabled": false,
        "mac_addresses": null,
        "email": "",
        "organization_name": "rsa-org-test",
        "bypass_secondary": false,
        "groups": [],
        "organization": "5fa001d043e2108e8ffb7a6d",
        "port_forwarding": [],
        "dns_servers": null,
        "type": "client",
        "id": "5fa001d143e2108e8ffb7a74"
    },
    "vpn_organization": "5fa10a25ccb8d1bdb79feeeb",
    "identification_number": "fdf",
    "_links": {
        "self": {
            "title": "Host",
            "href": "hosts/medpc-271e56.localdomain"
        },
        "related": {
            "last_action": {
                "title": "Action",
                "href": "actions/20201111130724122307medpc-271e56.localdomain"
            },
             "groups": [
                {
                   "title": "Group",
                   "href": "groups/5f8da6501eb86343459e26ce"
                 }
            ],
            "nodegroups": [
                {
                    "title": "Nodegroup",
                    "href": "nodegroups/medpc-img"
                },
                {
                    "title": "Nodegroup",
                    "href": "nodegroups/linux"
                }
            ],
            "vpn_organization": {
                "title": "Vpn_organization",
                "href": "vpn_organizations/5fa10a25ccb8d1bdb79feeeb"
            }
        },
        "parent": {
            "title": "home",
            "href": "/"
        },
        "collection": {
            "title": "hosts",
            "href": "hosts"
        }
    }
}
POST
/api/hosts/{id}
Performing an action on host

Request

Request options:

This endpoint is POST request proxy to http://salt-api/. But “salt_client” option is replaced by “client” and “tgt” is set to the hostname. See all possible functions can be found at Salt Module Reference.

Request example:

curl -X POST http://tkcontrol/api/hosts/skupov-staging-tkcontrol-non-root-client1 -H "Content-Type: application/json" -d '{ \
     { \
         "salt_client": "local", \
         "fun": "cmd.run", \
         "kwarg": { \
             "cmd": "ip a" \
         } \
     }'

Response

Response example:

{
    "task_id":"603e3a423f97526801fd3175",
    "status":"success",
    "return":{
        "return":[
            {
                "skupov-staging-tkcontrol-non-root-client1":"1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000\n    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00\n    inet 127.0.0.1/8 scope host lo\n       valid_lft forever preferred_lft forever\n    inet6 ::1/128 scope host \n       valid_lft forever preferred_lft forever\n2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000\n    link/ether fa:16:3e:b1:9d:9a brd ff:ff:ff:ff:ff:ff\n    inet 10.40.129.70/24 brd 10.40.129.255 scope global dynamic ens3\n       valid_lft 82940sec preferred_lft 82940sec\n    inet6 fe80::f816:3eff:feb1:9d9a/64 scope link \n       valid_lft forever preferred_lft forever"
            }
        ]
    }
}
POST
/api/hosts/{id}/all_status
Getting monitoring data about the host

Request

Request options:

Name In Type Description
action (Optional) body string Action to be performed on monitoring data. Possible actions are ‘start’, ‘stop’, ‘stop_all’.

Request example:

curl -X POST http://tkcontrol/api/hosts/skupov-salt-minion-dev5/all_status -H "Content-Type: application/json" -d '{ \
     { \
         "action":"start" \
     }'
PATCH
/api/hosts/{id}
Changing host by id

Request

Request example:

curl -X PATCH http://tkcontrol/api/hosts/skupov-salt-minion-dev5 -H "Content-Type: application/json" -d '{ \
     { \
         "identification_number":"123456789abc" \
     }'
DELETE
/api/hosts/{id}
Hiding host by id

Request

Request example:

curl -X DELETE http://tkcontrol/api/hosts/win7-lexa.center.cg

Hosts statistic

In practice, you don’t have to use this endpoint.

For statistics, refer to Aggregated statistic.

Scheme: hosts statistic.

GET
/api/hosts_statistic
Getting list of host statistics

Request

Request options:

Name In Type Description
where (Optional) url parameters JSON object Element filter. Used mongo query syntax.
sort (Optional) url parameters string Sorting items.
projection (Optional) url parameters JSON object Hiding fields.
embedded (Optional) url parameters JSON object Embedding items in fields.
page (Optional) url parameters integer Item page number.
max_results (Optional) url parameters integer Maximum number of items per page.

Request example:

curl -X GET http://tkcontrol/api/hosts_statistic?max_results=1

Response

Response example:

{
   "_items": [
       {
           "_id": "5e95d212a064b3e2fd6c8524",
           "hosts": [
                {
                   "_id": "skupov-salt-minion-dev2",
                   "version": "2",
                   "ip": "10.10.19.67",
                   "nodegroups": [
                      "skupov-img",
                      "linux"
                   ],
                    "_updated": "Tue, 14 Apr 2020 15:08:52 GMT",
                    "_created": "Tue, 14 Apr 2020 15:08:52 GMT",
                    "_soft_deleted": false
                }
            ],
            "timestamp": "Tue, 14 Apr 2020 15:09:06 GMT",
            "index": 1,
            "_created": "Thu, 01 Jan 1970 00:00:00 GMT",
            "_updated": "Thu, 01 Jan 1970 00:00:00 GMT",
            "_links": {
               "self": {
                    "title": "Hosts_statistic",
                    "href": "hosts_statistic/5e95d212a064b3e2fd6c8524"
               }
            }
        }
    ],
    "_links": {
       "parent": {
            "title": "home",
            "href": "/"
        },
        "self": {
            "title": "hosts_statistic",
            "href": "hosts_statistic?max_results=1"
        },
        "next": {
            "title": "next page",
            "href": "hosts_statistic?max_results=1&page=2"
        },
        "last": {
            "title": "last page",
            "href": "hosts_statistic?max_results=1&page=31139"
        }
   },
   "_meta": {
       "page": 1,
       "max_results": 1,
       "total": 31139
   }
}
GET
/api/hosts_statistic/{id}
Getting statistics on id

Request

Request options:

Name In Type Description
projection (Optional) url parameters JSON object Hiding fields.
embedded (Optional) url parameters JSON object Embedding items in fields.

Request example:

curl -X GET http://tkcontrol/api/hosts_statistic/5e95d212a064b3e2fd6c8524

Response

Response example:

{
    "_id": "5e95d212a064b3e2fd6c8524",
    "hosts": [
        {
             "_id": "skupov-salt-minion-dev2",
             "version": "2",
             "ip": "10.10.19.67",
             "nodegroups": [
                 "skupov-img",
                 "linux"
             ],
             "_updated": "Tue, 14 Apr 2020 15:08:52 GMT",
             "_created": "Tue, 14 Apr 2020 15:08:52 GMT",
             "_deleted": false
        }
    ],
     "timestamp": "Tue, 14 Apr 2020 15:09:06 GMT",
     "index": 1,
     "_created": "Thu, 01 Jan 1970 00:00:00 GMT",
     "_updated": "Thu, 01 Jan 1970 00:00:00 GMT",
     "_links": {
         "self": {
             "title": "Hosts_statistic",
             "href": "hosts_statistic/5e95d212a064b3e2fd6c8524"
         },
         "parent": {
             "title": "home",
             "href": "/"
         },
         "collection": {
             "title": "hosts_statistic",
             "href": "hosts_statistic"
         }
     }
 }

Nodegroups

Scheme: nodegroups.

GET
/api/nodegroups
Getting list of nodegroups

Request

Request options:

Name In Type Description
where (Optional) url parameters JSON object Element filter. Used mongo query syntax.
sort (Optional) url parameters string Sorting items.
projection (Optional) url parameters JSON object Hiding fields.
embedded (Optional) url parameters JSON object Embedding items in fields.
page (Optional) url parameters integer Item page number.
max_results (Optional) url parameters integer Maximum number of items per page.

Request example:

curl -X GET http://tkcontrol/api/nodegroups

Response

Response example:

{
    "_items": [
        {
            "_id": "5eb51ee46b1229b259e8f399",
            "name": "medpc-img",
            "type": 1,
            "info": {
                "regex": "medpc-.*",
                "grain": {
                    "osfullname": "ALT",
                    "cpuarch": "x86_64"
                }
            },
            "_updated": "Fri, 08 May 2020 08:57:08 GMT",
            "_created": "Fri, 08 May 2020 08:57:08 GMT",
            "_links": {
                "self": {
                    "title": "Nodegroup",
                    "href": "nodegroups/5eb51ee46b1229b259e8f399"
                }
            }
        },
        {
            "_id": "5eb51ee46b1229b259e8f39a",
            "name": "linux",
            "type": 1,
            "info": {
                "grain": {
                    "kernel": "Linux"
                }
            },
            "_updated": "Fri, 08 May 2020 08:57:08 GMT",
            "_created": "Fri, 08 May 2020 08:57:08 GMT",
            "_links": {
                "self": {
                    "title": "Nodegroup",
                    "href": "nodegroups/5eb51ee46b1229b259e8f39a"
                }
            }
        }
    ],
    "_links": {
        "parent": {
            "title": "home",
            "href": "/"
        },
        "self": {
            "title": "nodegroups",
            "href": "nodegroups"
        }
   },
    "_meta": {
        "page": 1,
        "max_results": 25,
        "total": 2
   }
}
GET
/api/nodegroups/{name}
Getting nodegroup by name

Request

Request options:

Name In Type Description
projection (Optional) url parameters JSON object Hiding fields.
embedded (Optional) url parameters JSON object Embedding items in fields.

Request example:

curl -X GET http://tkcontrol/api/nodegroups/medpc-img

Response

Response example:

 {
    "_id": "5eb51ee46b1229b259e8f399",
    "name": "medpc-img",
    "type": 1,
    "info": {
        "regex": "medpc-.*",
        "grain": {
           "osfullname": "ALT",
           "cpuarch": "x86_64"
        }
    },
    "_updated": "Fri, 08 May 2020 08:57:08 GMT",
    "_created": "Fri, 08 May 2020 08:57:08 GMT",
    "_links": {
        "self": {
            "title": "Nodegroup",
            "href": "nodegroups/5eb51ee46b1229b259e8f399"
        },
        "parent": {
            "title": "home",
            "href": "/"
        },
        "collection": {
            "title": "nodegroups",
            "href": "nodegroups"
        }
    }
}

Settings

Scheme: settings.

GET
/api/settings
Getting list of settings

Request

Request options:

Name In Type Description
where (Optional) url parameters JSON object Element filter. Used mongo query syntax.
sort (Optional) url parameters string Sorting items.
projection (Optional) url parameters JSON object Hiding fields.
embedded (Optional) url parameters JSON object Embedding items in fields.
page (Optional) url parameters integer Item page number.
max_results (Optional) url parameters integer Maximum number of items per page.

Request example:

curl -X GET http://tkcontrol/api/settings

Response

Response example:

{
   "_items": [
        {
            "_id": "0",
            "_updated": "Tue, 29 Sep 2020 09:55:41 GMT",
            "_created": "Fri, 25 Sep 2020 13:47:16 GMT",
            "addresses": {
                "resolver_address": "",
                "master_address": "config.dev",
                "file": "5f73049d836e90817cbccaab"
            },
            "_links": {
                "self": {
                    "title": "Setting",
                    "href": "settings/0"
                }
            }
        }
    ],
    "_links": {
        "parent": {
            "title": "home",
            "href": "/"
        },
        "self": {
            "title": "settings",
            "href": "settings"
        }
    },
    "_meta": {
        "page": 1,
        "max_results": 25,
        "total": 1
    }
}
GET
/api/settings/{id}
Getting settings by id

Request

Request options:

Name In Type Description
projection (Optional) url parameters JSON object Hiding fields.
embedded (Optional) url parameters JSON object Embedding items in fields.

Request example:

curl -X GET http://tkcontrol/api/settings/0

Response

Response example:

{
    "_id": "0",
    "_updated": "Tue, 29 Sep 2020 09:55:41 GMT",
    "_created": "Fri, 25 Sep 2020 13:47:16 GMT",
    "addresses": {
    "resolver_address": "",
    "master_address": "config.dev",
    "file": "5f73049d836e90817cbccaab"
},
"_links": {
    "self": {
        "title": "Setting",
        "href": "settings/0"
    },
    "parent": {
        "title": "home",
        "href": "/"
        },
        "collection": {
            "title": "settings",
            "href": "settings"
        }
    }
}
PATCH
api/settings/{id}
Changing settings by id

Request

Request example:

curl -X PATCH http://tkcontrol/api/settings/0 -H "Content-Type: application/json" -d '{ \
     { \
         "resolver_address": "10.10.19.156" \
     }'

Tasks

Scheme: tasks.

GET
/api/tasks
Getting list of tasks

Request

Request options:

Name In Type Description
where (Optional) url parameters JSON object Element filter. Used mongo query syntax.
sort (Optional) url parameters string Sorting items.
projection (Optional) url parameters JSON object Hiding fields.
embedded (Optional) url parameters JSON object Embedding items in fields.
page (Optional) url parameters integer Item page number.
max_results (Optional) url parameters integer Maximum number of items per page.

Request example:

curl -X GET http://tkcontrol/api/tasks

Response

Response example:

{
    "_items": [
        {
            "_id": "5eb55bc3f0e593e6ec94f3ca",
            "salt_client": "local_async",
            "name": "New Task",
            "fun": "cmd.run",
            "kwarg": {
               "cmd": "uname"
            },
           "start": "Fri, 08 May 2020 00:00:00 GMT",
            "status": "scheduled",
            "tgt": [
                "medpc-fe5f87.localdomain",
                "medpc-6616cd.localdomain"
            ],
            "interval": 180,
            "end": "Sat, 09 May 2020 00:00:00 GMT",
            "next": "Fri, 08 May 2020 13:20:00 GMT",
            "count_of_execution": 1,
            "_updated": "Fri, 08 May 2020 13:17:23 GMT",
            "_created": "Fri, 08 May 2020 13:16:51 GMT",
            "_links": {
                "self": {
                    "title": "Task",
                    "href": "tasks/5eb55bc3f0e593e6ec94f3ca"
                }
            }
        }
    ],
    "_links": {
        "parent": {
            "title": "home",
            "href": "/"
        },
        "self": {
            "title": "tasks",
            "href": "tasks"
        }
    },
    "_meta": {
        "page": 1,
        "max_results": 25,
        "total": 1
    }
}
GET
/api/tasks/{id}
Getting task by id

Request

Request options:

Name In Type Description
projection (Optional) url parameters JSON object Hiding fields.
embedded (Optional) url parameters JSON object Embedding items in fields.

Request example:

curl -X GET http://tkcontrol/api/tasks/5eb55bc3f0e593e6ec94f3ca

Response

Response example:

{
    "_id": "5eb55bc3f0e593e6ec94f3ca",
    "salt_client": "local_async",
    "name": "New Task",
    "fun": "cmd.run",
    "kwarg": {
        "cmd": "uname"
     },
    "start": "Fri, 08 May 2020 00:00:00 GMT",
    "status": "scheduled",
     "tgt": [
        "medpc-fe5f87.localdomain",
        "medpc-6616cd.localdomain"
    ],
    "interval": 180,
    "end": "Sat, 09 May 2020 00:00:00 GMT",
    "next": "Fri, 08 May 2020 13:20:00 GMT",
    "count_of_execution": 1,
    "_updated": "Fri, 08 May 2020 13:17:23 GMT",
    "_created": "Fri, 08 May 2020 13:16:51 GMT",
    "_links": {
        "self": {
            "title": "Task",
            "href": "tasks/5eb55bc3f0e593e6ec94f3ca"
        },
        "parent": {
            "title": "home",
            "href": "/"
        },
        "collection": {
            "title": "tasks",
            "href": "tasks"
        }
    }
}
POST
/api/tasks
Creating new task

Request

Request example:

curl -X POST http://tkcontrol/api/tasks -H "Content-Type: application/json" -d '{ \
     { \
         "salt_client": "local_async", \
         "name": "Super task", \
         "fun": "cmd.run", \
         "kwarg": { \
             "cmd": "ls /" \
         }, \
         "start": "2020-05-14 00:03", \
         "status": "scheduled", \
         "tgt": [ \
             "salt-minion-staging-1" \
         ] \
     }'
PATCH
/api/tasks/{id}/{status}
Changing task status

Request example:

curl -X PATCH http://tkcontrol/api/tasks/5eb55c83f0e593e6ec94f3cb/paused
PUT
/api/tasks
Changing task

Request example:

curl -X PUT http://tkcontrol/api/tasks -H "Content-Type: application/json" -d '{ \
     { \
         "tgt": [ \
             "salt-minion-staging-1", \
             "salt-minion-2" \
         ] \
     }'
DELETE
/api/tasks/{id}
Deleting task by id

Request example:

curl -X DELETE http://tkcontrol/api/tasks/5eb55c83f0e593e6ec94f3cb

Updates

Scheme: updates.

GET
api/updates
Getting list of patches

Request

Request options:

Name In Type Description
where (Optional) url parameters JSON object Element filter. Used mongo query syntax.
sort (Optional) url parameters string Sorting items.
projection (Optional) url parameters JSON object Hiding fields.
embedded (Optional) url parameters JSON object Embedding items in fields.
page (Optional) url parameters integer Item page number.
max_results (Optional) url parameters integer Maximum number of items per page.

Request example:

curl -X GET http://tkcontrol/api/updates

Response

Response example:

{
    "_items": [
        {
            "_id": "5eb54eb4f0e593e6ec94f3ac",
            "name": "add-grain.sls",
            "text": "some sls file",
            "_updated": "Fri, 08 May 2020 12:21:08 GMT",
            "_created": "Fri, 08 May 2020 12:21:08 GMT",
            "_links": {
                "self": {
                    "title": "Update",
                    "href": "updates/5eb54eb4f0e593e6ec94f3ac"
                }
            }
        },
        {
            "_id": "5eb54eb4f0e593e6ec94f3ad",
            "name": "patch-1.sls",
            "text": "some patch",
            "_updated": "Fri, 08 May 2020 12:21:08 GMT",
            "_created": "Fri, 08 May 2020 12:21:08 GMT",
            "_links": {
                "self": {
                    "title": "Update",
                    "href": "updates/5eb54eb4f0e593e6ec94f3ad"
                }
            }
        },
    ],
    "_links": {
        "parent": {
            "title": "home",
            "href": "/"
        },
        "self": {
            "title": "updates",
            "href": "updates"
        },
        "next": {
            "title": "next page",
            "href": "updates?page=2"
        },
        "last": {
            "title": "last page",
            "href": "updates?page=2"
        }
    },
    "_meta": {
        "page": 1,
        "max_results": 25,
        "total": 2
    }
}
GET
/api/updates/{id}
Getting patch by id

Request

Request options:

Name In Type Description
projection (Optional) url parameters JSON object Hiding fields.
embedded (Optional) url parameters JSON object Embedding items in fields.

Request example:

curl -X GET http://tkcontrol/api/updates/5eb54eb4f0e593e6ec94f3ac

Response

Response example:

{
    "_id": "5eb54eb4f0e593e6ec94f3ac",
    "name": "add-grain.sls",
    "text": "some sls file",
    "_updated": "Fri, 08 May 2020 12:21:08 GMT",
    "_created": "Fri, 08 May 2020 12:21:08 GMT",
    "_links": {
        "self": {
            "title": "Update",
            "href": "updates/5eb54eb4f0e593e6ec94f3ac"
        },
        "parent": {
        "title": "home",
            "href": "/"
        },
      "collection": {
            "title": "updates",
            "href": "updates"
        }
    }
}
POST
/api/updates
Downloading patches from saltmaster

Request

Request example:

curl -X POST http://tkcontrol/api/updates
PATCH
/api/updates/{id}
Changing patch locally by id

Request

Request example:

curl -X PATCH http://tkcontrol/api/updates/5eb54eb4f0e593e6ec94f3ad -H "Content-Type: application/json" -d '{ \
     { \
         "description": "First patch" \
     }'

VPN Managers

Scheme: vpn_managers.

GET
/api/vpn_managers
Getting list of VPN Managers

Request

Request options:

Name In Type Description
where (Optional) url parameters JSON object Element filter. Used mongo query syntax.
sort (Optional) url parameters string Sorting items.
projection (Optional) url parameters JSON object Hiding fields.
embedded (Optional) url parameters JSON object Embedding items in fields.
page (Optional) url parameters integer Item page number.
max_results (Optional) url parameters integer Maximum number of items per page.

Request example:

curl -X GET http://tkcontrol/api/vpn_managers?sort=name&page=1&max_results=10

Response

Response example:

{
    "_items": [
        {
            "_id": "5fa10a15ccb8d1bdb79feee9",
            "name": "skupov-dev-pritunl",
            "server_address": "10.10.56.124",
            "dashboard_address": "https://10.10.56.124",
            "username": "pritunl",
            "password": "*******",
            "_updated": "Tue, 03 Nov 2020 07:43:17 GMT",
            "_created": "Tue, 03 Nov 2020 07:43:17 GMT",
            "_links": {
                "self": {
                    "title": "Vpn_manager",
                    "href": "vpn_managers/5fa10a15ccb8d1bdb79feee9"
                }
            }
        }
    ],
    "_links": {
        "parent": {
            "title": "home",
            "href": "/"
        },
        "self": {
             "title": "vpn_managers",
             "href": "vpn_managers?max_results=10&sort=name"
        }
    },
    "_meta": {
        "page": 1,
        "max_results": 10,
        "total": 1
    }
}
GET
/api/vpn_managers/{id}
Getting VPN Manager by id

Request

Request options:

Name In Type Description
projection (Optional) url parameters JSON object Hiding fields.
embedded (Optional) url parameters JSON object Embedding items in fields.

Request example:

curl -X GET http://tkcontrol/api/vpn_managers/5fa10a15ccb8d1bdb79feee9

Response

Response example:

{
    "_id": "5fa10a15ccb8d1bdb79feee9",
    "name": "skupov-dev-pritunl",
    "server_address": "10.10.56.124",
    "dashboard_address": "https://10.10.56.124",
    "username": "pritunl",
    "password": "*******",
    "_updated": "Tue, 03 Nov 2020 07:43:17 GMT",
    "_created": "Tue, 03 Nov 2020 07:43:17 GMT",
    "_links": {
        "self": {
            "title": "Vpn_manager",
            "href": "vpn_managers/5fa10a15ccb8d1bdb79feee9"
        },
        "parent": {
            "title": "home",
            "href": "/"
        },
        "collection": {
            "title": "vpn_managers",
            "href": "vpn_managers"
        }
    }
}
POST
/api/vpn_managers
Creating VPN Manager

Request

Request example:

curl -X POST http://tkcontrol/api/vpn_managers -H "Content-Type: application/json" -d '{ \
     { \
         "dashboard_address": "https://10.10.56.124", \
         "name": "example_vpn_manager", \
         "server_address": "10.10.56.124", \
         "username": "pritunl", \
         "password": "some_pass", \
     }'

Response

Response example:

{
    "_updated": "Fri, 18 Dec 2020 08:42:49 GMT",
    "_created": "Fri, 18 Dec 2020 08:42:49 GMT",
    "_id": "5fdc6b8998305492eb558cd4",
    "_links": {
        "self": {
            "title": "Vpn_manager",
            "href": "vpn_managers/5fdc6b8998305492eb558cd4"
        }
    },
    "_status": "OK"
}
DELETE
/api/vpn_managers/{id}
Deleting VPN Manager by id

Request

Request example:

curl -X DELETE http://tkcontrol/api/vpn_managers/5fdc6b8998305492eb558cd4

VPN Organizations

Scheme: vpn_organizations.

GET
/api/vpn_organizations
Getting list of VPN Organizations

Request

Request options:

Name In Type Description
where (Optional) url parameters JSON object Element filter. Used mongo query syntax.
sort (Optional) url parameters string Sorting items.
projection (Optional) url parameters JSON object Hiding fields.
embedded (Optional) url parameters JSON object Embedding items in fields.
page (Optional) url parameters integer Item page number.
max_results (Optional) url parameters integer Maximum number of items per page.

Request example:

curl -X GET http://tkcontrol/api/vpn_organizations?sort=name&page=1&max_results=10&embedded={"vpn_manager":1}

Response

Response example:

{
    "_items": [
        {
            "_id": "5fa10a25ccb8d1bdb79feeeb",
            "name": "rsa-org-test",
            "vpn_manager": {
                "_id": "5fa10a15ccb8d1bdb79feee9",
                "name": "skupov-dev-pritunl",
                "server_address": "10.10.56.124",
                "dashboard_address": "https://10.10.56.124",
                "username": "pritunl",
                "password": "******",
                "_updated": "Tue, 03 Nov 2020 07:43:17 GMT",
                "_created": "Tue, 03 Nov 2020 07:43:17 GMT"
            },
            "pritunl_representation": {
                "auth_api": false,
                "name": "rsa-org-test",
                "auth_token": null,
                "user_count": 0,
                "auth_secret": null,
                "id": "5fa001d043e2108e8ffb7a6d"
             },
             "type": 6,
             "_updated": "Tue, 03 Nov 2020 07:43:32 GMT",
             "_created": "Tue, 03 Nov 2020 07:43:32 GMT",
             "_links": {
                "self": {
                    "title": "Vpn_organization",
                    "href": "vpn_organizations/5fa10a25ccb8d1bdb79feeeb"
                },
                "related": {
                    "vpn_manager": {
                        "title": "Vpn_manager",
                        "href": "vpn_managers/5fa10a15ccb8d1bdb79feee9"
                    }
                }
            }
        }
    ],
    "_links": {
        "parent": {
             "title": "home",
             "href": "/"
        },
        "self": {
            "title": "vpn_organizations",
            "href": "vpn_organizations?max_results=10&sort=name"
        }
    },
    "_meta": {
        "page": 1,
        "max_results": 10,
        "total": 1
    }
}
GET
/api/vpn_organizations/{id}
Getting VPN Organization by id

Request

Request options:

Name In Type Description
projection (Optional) url parameters JSON object Hiding fields.
embedded (Optional) url parameters JSON object Embedding items in fields.

Request example:

curl -X GET http://tkcontrol/api/vpn_organizations/5fa10a25ccb8d1bdb79feeeb

Response

Response example:

{
    "_id": "5fa10a25ccb8d1bdb79feeeb",
    "name": "rsa-org-test",
    "vpn_manager": "5fa10a15ccb8d1bdb79feee9",
    "pritunl_representation": {
        "auth_api": false,
        "name": "rsa-org-test",
        "auth_token": null,
        "user_count": 0,
        "auth_secret": null,
        "id": "5fa001d043e2108e8ffb7a6d"
    },
    "type": 6,
    "_updated": "Tue, 03 Nov 2020 07:43:32 GMT",
    "_created": "Tue, 03 Nov 2020 07:43:32 GMT",
    "_links": {
        "self": {
            "title": "Vpn_organization",
            "href": "vpn_organizations/5fa10a25ccb8d1bdb79feeeb"
        },
        "related": {
            "vpn_manager": {
                "title": "Vpn_manager",
                "href": "vpn_managers/5fa10a15ccb8d1bdb79feee9"
            }
        },
        "parent": {
            "title": "home",
            "href": "/"
        },
        "collection": {
            "title": "vpn_organizations",
            "href": "vpn_organizations"
        }
    }
}
POST
/api/vpn_organizations
Creating VPN Organization

Request

Request example:

curl -X POST http://tkcontrol/api/vpn_organizations -H "Content-Type: application/json" -d '{ \
     { \
         "name": "example_organization", \
         "pritunl_representation": { \
             "name": "example_organization", \
             "cipher_type": "rsa" \
         }, \
         "cipher_type": "rsa", \
         "name": "example_organization", \
         "vpn_manager": "5fdc6b8998305492eb558cd4" \
     }'

Response

Response example:

{
    "_updated": "Fri, 18 Dec 2020 08:57:33 GMT",
    "_created": "Fri, 18 Dec 2020 08:57:33 GMT",
    "_id": "5fdc6efd98305492eb558cd6",
    "_links": {
        "self": {
            "title": "Vpn_organization",
            "href": "vpn_organizations/5fdc6efd98305492eb558cd6"
        },
        "related": {
            "vpn_manager": {
                "title": "Vpn_manager",
                "href": "vpn_managers/5fdc6b8998305492eb558cd4"
            }
        }
    },
   "_status": "OK"
}
DELETE
/api/vpn_organizations/{id}
Deleting VPN Organization by id

Request

Request example:

curl -X DELETE http://tkcontrol/api/vpn_organizations/5fdc6efd98305492eb558cd6