HW agent API 2.15.3

Раздел 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обязательныйquerystring

Ответ 200 application/json

Поля · FileContent
  • pathstring
  • textstring
  • base64string

Ошибки — 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обязательныйquerystring

Тело запроса application/json обязательное

Поля · FileContent
  • pathstring
  • textstring
  • base64string
JSON
{
  "path": "string",
  "text": "string",
  "base64": "string"
}

Ответ 200 application/json

Поля · FileInfo
  • pathstring
  • sizeinteger int64
  • modifiedstring date-time
  • directoryboolean

Ошибки — 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
  • machineIdstring
  • hostnamestring
  • userstring
  • osstring
  • osVersionstring
  • archstring
  • agentVersionstring
  • interfacesмассив Interface
    6 полей · Interface
    • namestring
    • displayNamestring
    • macstring
    • ipv4массив string
    • ipv6массив string
    • virtualboolean

Ошибки — 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 — подпапка, пусто — корень

Параметры

ИмяГдеТипОписание
dirquerystring

Ответ 200 application/json

Массив · FileInfo
  • pathstring
  • sizeinteger int64
  • modifiedstring date-time
  • directoryboolean

Ошибки — 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обязательныйquerystring

Ответ 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'