Agent Local API Reference

The Agent daemon supports a local API with REST-like endpoints as well as WebSockets.

API Endpoints

Get Container Configuration

This endpoint provides the current JSON configuration string for the requesting container. Containers identify themselves by their element ID, which is mapped into the container as an environment variable.

Endpoint
http://iofog:54321/v2/config/get
Response
{
  "status": "okay",
  "config": "{\"property1\":\"value1\",\"property2\":\"value2\"}"
}
Querystring Parameters
	None
POST Parameters
{
  "id": "R4b2WPZRbycCzyZBz9tD7BdMWg94YDhQ"

  // Note: The POST value is JSON and must be sent
  // with HTTP header set as “Content-Type:application/json”
}

Get Control Websocket Connection

This endpoint opens a control Websocket connection for the container. The control commands sent over this Websocket are specified here. It is the responsibility of the container to establish this connection and ensure it is always running. If the container loses the Websocket connection, it should establish a new connection. The Local API is responsible for knowing which Websocket connection belongs to which container so that it can pass information to the appropriate recipients.

The container ID must be passed as part of the URL because otherwise it would have to be passed in the Websocket connection itself and that would make associated connections with container IDs rather difficult.

Endpoint
ws://iofog:54321/v2/control/socket/id/34t9whefsdfDFKjhw4tiouhwef
Response
None - the Websocket will simply be opened successfully
Querystring Parameters
id - the container ID of the container requesting the Websocket connection (example shown here as 34t9whefsdfDFKjhw4tiouhwef)
POST Parameters
None
Transmissions From ioFog To Container
Standard "Ping" message (op code 9)
Standard "Pong" message (op code 10)
Acknowledgement message (op code 11)
New container configuration available (op code 12)
Transmissions From Container To ioFog
Standard "Ping" message (op code 9)
Standard "Pong" message (op code 10)
Acknowledgement message (op code 11)

Get service status

This endpoint return service status, same as cli command iofog-agent status.

Endpoint
http://iofog:54321/v2/status
Method
GET
Authorization (authorization key can be found in /etc/iofog-agent/local-api file)
Response
{
  "running-microservices": "string",
  "system-total-cpu": "string",
  "memory-usage": "string",
  "system-available-memory": "string",
  "system-time": "string",
  "disk-usage": "string",
  "connection-to-controller": "string",
  "cpu-usage": "string",
  "messages-processed": "string",
  "system-available-disk": "string",
  "iofog-daemon": "string"
}
Querystring Parameters
None

Get service info

This endpoint return service info, same as cli command iofog-agent info.

Endpoint
http://iofog:54321/v2/info
Method
GET
Header
Authorization (authorization key can be found in /etc/iofog-agent/local-api file)
Response
{
  "log-file-directory": "string",
  "iofog-controller": "string",
  "cpu-usage-limit": "string",
  "developer-mode": "string",
  "post-diagnostics-frequency": "string",
  "docker-url": "string",
  "status-update-frequency": "string",
  "memory-ram-limit": "string",
  "log-disk-limit": "string",
  "isolated-docker-containers-mode": "string",
  "iofog-certificate": "string",
  "ip-address": "string",
  "network-interface": "string",
  "fog-type": "string",
  "disk-usage-limit": "string",
  "iofog-uuid": "string",
  "gps-mode": "string",
  "message-storage-directory": "string",
  "get-changes-frequency": "string",
  "gps-coordinates": "string",
  "log-rolling-file-count": "string",
  "scan-devices-frequency": "string",
  "log-level": "string",
  "docker-pruning-frequency": "string",
  "disk-threshold integer": "string"
}
Querystring Parameters
None

Get service version

This endpoint return service version, same as cli command iofog-agent version.

Endpoint
http://iofog:54321/v2/version
Method
GET
Header
Authorization (authorization key can be found in /etc/iofog-agent/local-api file)
Response
{
  "version": "3.0.0"
}
Querystring Parameters
None

Attach ioFog Agent to the configured ioFog controller

This endpoint attaches ioFog Agent to the configured ioFog controller, same as cli command iofog-agent provision <provisioning_key>.

Endpoint
http://iofog:54321/v2/provision
Method
POST
Header
Authorization (authorization key can be found in /etc/iofog-agent/local-api file)
Response
Success
Querystring Parameters
None
POST Parameters
{
  "provisioning-key": "string"
}

Detach ioFog Agent to the configured ioFog controller

This endpoint detaches ioFog Agent to the configured ioFog controller, same as cli command iofog-agent deprovision.

Endpoint
http://iofog:54321/v2/deprovision
Method
DELETE
Header
Authorization (authorization key can be found in /etc/iofog-agent/local-api file)
Response
Success
Querystring Parameters
None

Change ioFog Agent configuration according to the options provided

This endpoint changes ioFog Agent configuration according to the options provided, same as cli command iofog-agent config.

Endpoint
http://iofog:54321/v2/config
Method
POST
Header
Authorization (authorization key can be found in /etc/iofog-agent/local-api file)
Response
Success
Querystring Parameters
None
Post Parameters
{
  "disk-limit": "string",
  "disk-directory": "string",
  "memory-limit": "string",
  "cpu-limit": "string",
  "controller-url": "string",
  "cert-directory": "string",
  "docker-url": "string",
  "network-adapter": "string",
  "logs-limit": "string",
  "logs-directory": "string",
  "logs-count": "string",
  "status-frequency": "string",
  "changes-frequency": "string",
  "diagnostics-frequency": "string",
  "device-scan-frequency": "string",
  "isolated": "string",
  "gps": "string",
  "fog-type": "string",
  "developer-mode": "string",
  "log-level": "string",
  "docker-pruning-frequency": "string",
  "disk-threshold integer": "string"
}
Querystring Parameters
None

Prune iofog agent

This endpoint prunes ioFog Agent, same as cli command iofog-agent prune.

Endpoint
http://iofog:54321/v2/prune
Method
POST
Header
Authorization (authorization key can be found in /etc/iofog-agent/local-api file)
Response
Success