Раздел API
Компьютер и файлы
Сведения о компьютере и постоянный номер установки агента; файлы в разрешённой папке (если включены hw.files.enabled).
| GET | /api/v1/files/content | Прочитать файл |
| PUT | /api/v1/files/content | Записать файл |
| GET | /api/v1/system/computer | Сведения о компьютере |
| GET | /api/v1/files | Файлы в разрешённой папке |
| DELETE | /api/v1/files | Удалить файл |
Прочитать файл#
GET
/api/v1/files/contentСодержимое в base64 и, если это текст UTF-8, — text
Параметры
| Имя | Где | Тип | Описание |
|---|---|---|---|
pathобязательный | query | string |
Ответ 200 application/json
Поля · FileContent
pathstringtextstringbase64string
Ошибки — problem+json с полем code, см. коды ошибок.
Пример запроса
curl
curl 'http://localhost:7790/api/v1/files/content?path=text'curl
curl 'https://cloud.hw-connector.ru/agent/api/v1/files/content?path=text' \
-H 'X-Api-Key: hwk_…' \
-H 'X-Device-Id: 42'Записать файл#
PUT
/api/v1/files/contentТело {text} или {base64}; подпапки создаются; файл заменяется целиком
Параметры
| Имя | Где | Тип | Описание |
|---|---|---|---|
pathобязательный | query | string |
Тело запроса application/json обязательное
Поля · FileContent
pathstringtextstringbase64string
JSON
{
"path": "string",
"text": "string",
"base64": "string"
}Ответ 200 application/json
Поля · FileInfo
pathstringsizeinteger int64modifiedstring date-timedirectoryboolean
Ошибки — problem+json с полем code, см. коды ошибок.
Пример запроса
curl
curl -X PUT 'http://localhost:7790/api/v1/files/content?path=text' \
-H 'Content-Type: application/json' \
--data '{"path":"string","text":"string","base64":"string"}'curl
curl -X PUT 'https://cloud.hw-connector.ru/agent/api/v1/files/content?path=text' \
-H 'X-Api-Key: hwk_…' \
-H 'X-Device-Id: 42' \
-H 'Content-Type: application/json' \
--data '{"path":"string","text":"string","base64":"string"}'Сведения о компьютере#
GET
/api/v1/system/computerИмя, пользователь, ОС, сетевые карты (MAC, IP) и постоянный machineId агента
Ответ 200 application/json
Поля · Computer
machineIdstringhostnamestringuserstringosstringosVersionstringarchstringagentVersionstringinterfacesмассив Interface6 полей · Interface
namestringdisplayNamestringmacstringipv4массив stringipv6массив stringvirtualboolean
Ошибки — problem+json с полем code, см. коды ошибок.
Пример запроса
curl
curl 'http://localhost:7790/api/v1/system/computer'curl
curl 'https://cloud.hw-connector.ru/agent/api/v1/system/computer' \
-H 'X-Api-Key: hwk_…' \
-H 'X-Device-Id: 42'Файлы в разрешённой папке#
GET
/api/v1/filesВключается hw.files.enabled; dir — подпапка, пусто — корень
Параметры
| Имя | Где | Тип | Описание |
|---|---|---|---|
dir | query | string |
Ответ 200 application/json
Массив · FileInfo
pathstringsizeinteger int64modifiedstring date-timedirectoryboolean
Ошибки — problem+json с полем code, см. коды ошибок.
Пример запроса
curl
curl 'http://localhost:7790/api/v1/files'curl
curl 'https://cloud.hw-connector.ru/agent/api/v1/files' \
-H 'X-Api-Key: hwk_…' \
-H 'X-Device-Id: 42'Удалить файл#
DELETE
/api/v1/filesПараметры
| Имя | Где | Тип | Описание |
|---|---|---|---|
pathобязательный | query | string |
Ответ 200
Без тела.
Ошибки — problem+json с полем code, см. коды ошибок.
Пример запроса
curl
curl -X DELETE 'http://localhost:7790/api/v1/files?path=text'curl
curl -X DELETE 'https://cloud.hw-connector.ru/agent/api/v1/files?path=text' \
-H 'X-Api-Key: hwk_…' \
-H 'X-Device-Id: 42'