Graph

GET
api/graph/{id}
Получение графа, где корень это группа с данным id

Запрос

Пример запроса:

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

Ответ

Пример ответа:

{
    "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
Получение только узлов графа, где корень это группа с данным id

Запрос

Параметры запроса:

Name

In

Type

Description

where (Optional)

url parameters

JSON object

Фильтр узлов. Принимает аргумент 'type' типа 'integer'.

Пример запроса:

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

Ответ

Пример ответа:

{
   "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
Получение только связей графа, где корень это группа с данным id

Пример запроса:

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

Ответ

Пример ответа:

{
    "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
Получение неприкрепленных gateways

Запрос

Пример запроса:

curl -X GET http://tkcontrol/
POST
/api/graph
Выполнить действие над обработчиком графа

Запрос

Параметры запроса:

Name

In

Type

Description

action (Optional)

body

string

Действие, которое необходимо выполнить над графом. Возможные действия: 'request_ips', 'build_graph'.

ip_resolver (Optional)

body

string

URL-адрес ip resolver. Используется только с действием 'request_ips'.

master (Optional)

body

string

Имя master сервера. Используется только с действием 'build_graph'.

Пример запроса:

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" \
}'