Edge Core API
Edge Core API
The Edge Core API allows users to interact with the system utilizing the same underlying functionality as Edge Manager or the Predix Technician Edge Console (PETC). The API is accessible from inside the device when logged into a terminal via a Unix domain socket. The API can be used for development purposes to manage applications, configure the network, perform host updates, retrieve logs, etc.
The API is not accessible from outside the device and is subject to change in future releases.
Applications
Info
Gets details about the specified application.
GET
http://localhost/api/v1/applications/<app_name>
curl http://localhost/api/v1/applications/my-app \
--unix-socket /var/run/edge-core/edge-core.sock
{
"container_app_info": {
"application": {
"name": "my-app",
"service": [
{
"current_state": "Running 24 hours ago",
"desired_state": "Running",
"error_message": "",
"id": "fuz7x5vjru8w1li11fhgcixuu",
"image": "eh-server",
"name": "my-app_app2.1"
},
{
"current_state": "Running 24 hours ago",
"desired_state": "Running",
"error_message": "",
"id": "aiznk23c3mfpi7ltbk54hx5yp",
"image": "ds-server",
"name": "my-app_app1.1"
}
],
"version": ""
}
},
"platform_name": "Docker",
"platform_version": "Docker version 17.05.0-ce, build 89658be"
}
{
"error_message": "application not found: my-appx",
"status_code": 400
}
Delete
Deletes a deployed application.
DELETE
http://localhost/api/v1/applications/<app_name>
Field | Type | Description |
---|---|---|
app_name | String | Application name |
curl http://localhost/api/v1/applications/my-app \
--unix-socket /var/run/edge-core/edge-core.sock \
-X DELETE
Name | Type | Description |
---|---|---|
error_message | String | A description of the error encountered |
status_code | Number | Status code for the HTTP request |
{
"error_message": "<errorMessage>",
"status_code": 400
}
Deploy Configuration
Deploys the configuration of an application.
POST
http://localhost/api/v1/applications/<app_name>/configuration
Field | Type | Description |
---|---|---|
app_name | String | Application name |
file | String | Application configuration file |
curl http://localhost/api/v1/applications/my-app/configuration \
--unix-socket /var/run/edge-core/edge-core.sock \
-X POST \
-F "[email protected]/mnt/data/downloads/my-app-config.zip"
{
"app_config_deploy": "App configuration deployment successful."
}
{
"error_message": "Application with id my-app does not exist.
Unable to deploy configs.",
"status_code": 400
}
Deploy Application
Deploys an application
POST
http://localhost/api/v1/applications
Field | Type | Description |
---|---|---|
app_name | String | Application name |
file_name | String | Name of the application deployment file |
curl http://localhost/api/v1/applications \
--unix-socket /var/run/edge-core/edge-core.sock \
-X POST \
-F "[email protected]<file_name>" \
-H "app_name: my_app"
{
"app_deploy": "Application deployment successful."
}
{
"error_message": "gzip: stdin: unexpected end of file tar:
Child returned status 1 tar: Error is not recoverable:
exiting now",
"status_code": 400
}
Get List
Gets a list of applications.
GET
http://localhost/api/v1/applications
curl http://localhost/api/v1/applications \
--unix-socket /var/run/edge-core/edge-core.sock
{
"applications": [
"my-app",
"web-server",
"database"
]
}
Field | Type | Description |
---|---|---|
error_message | String | A description of the error encountered |
status_code | Number | Status code for the HTTP request |
{
"error_message": "<errorMessage>",
"status_code": 400
}
Start an Application
Starts an application.
POST
http://localhost/api/v1/applications/<app_name>/start
Field | Type | Description |
---|---|---|
app_name | String | Application name |
curl http://localhost/api/v1/applications/my-app/start \
--unix-socket /var/run/edge-core/edge-core.sock \
-X POST
Field | Type | Description |
---|---|---|
error_message | String | A description of the error encountered |
status_code | Number | Status code for the HTTP request |
{
"error_message": "<errorMessage>",
"status_code": 400
}
Stop an Application
Stops an application.
POST
http://localhost/api/v1/applications/<app_name>/stop
Field | Type | Description |
---|---|---|
app_name | String | Application name |
curl http://localhost/api/v1/applications/my-app/stop \
--unix-socket /var/run/edge-core/edge-core.sock \
-X POST
Field | Type | Description |
---|---|---|
error_message | String | A description of the error encountered |
status_code | Number | Status code for the HTTP request |
{
"error_message": "<errorMessage>",
"status_code": 400
}
Device
Get OS Info
Gets the OS information of the device.
GET
http://localhost/api/v1/host/os
curl --unix-socket /var/run/edge-core/edge-core.sock \
http://localhost/api/v1/host/os
Field | Type | Description |
---|---|---|
os_name | String | OS name |
os_version | String | OS version |
os_arch | String | OS architecture |
{
"os_name": "Edge OS",
"os_version": "2.0.0-beta.8",
"os_arch": "x86_64"
}
Get Update State
Gets the state of an update.
State is kept for the most recent update attempt, so querying with an older update_identifier will return “NO UPGRADE OCCURRED”. Note: update_identifier is required because there is a brief lag between the start of an update and the actual upgrade process running. So if a client starts an update and then immediately tries to get the ‘state’ before the upgrade process has started, without the id they would get the state of the previous update, an incorrect result.
GET
http://localhost/api/v1/host/state?update_identifier=<identifier>
Field | Type | Description |
---|---|---|
update_identifier | String | Identifier of the update |
curl --unix-socket /var/run/edge-core/edge-core.sock \
http://localhost/api/v1/host/state?update_identifier=<identifier>
Field | Type | Description |
---|---|---|
last_os_upgrade | String | State of the update associated with the identifier: "PASS", "FAIL", INPROGRESS" or "NO UPGRADE OCCURRED" |
{
"last_os_upgrade": "PASS"
}
Reboot
Reboots the device.
POST
http://localhost/api/v1/host/reboot
curl --unix-socket /var/run/edge-core/edge-core.sock \
-X POST http://localhost/api/v1/host/reboot
Upon successful completion of the operation, the box will reboot.
Update
Updates the Predix Edge OS and Edge Agent.
POST
http://localhost/api/v1/host/update
Field | Type | Description |
---|---|---|
update_identifier | String | An identifier associated with the update. Can be any string, as long as it is unique. |
file_name | String | Name of the Predix Edge OS/Edge Agent update image file. |
curl --unix-socket /var/run/edge-core/edge-core.sock \
-X POST -H "update_identifier: <identifier>" -F "[email protected]<file_name>" \
http://localhost/api/v1/host/update
If the update is successfully applied, the device will reboot to complete the update.
Field | Type | Description |
---|---|---|
error_message | String | A description of the error encountered |
status_code | Number | The status code for the HTTP request |
{
"error_message": "<errorMessage>",
"status_code": 500
}
Enrollment
Delete
Delete enrollment information for an enrolled device.
A reboot is required after removing enrollment information to ensure the device is no longer connected/enrolled to the Edge Manager. This does not unenroll a device from Edge Manager. A user will need to manually delete the device from Edge Manager.
DELETE
http://localhost/api/v1/host/enroll/
curl http://localhost/api/v1/host/enroll \
--unix-socket /var/run/edge-core/edge-core.sock \
-X DELETE
Field | Type | Description |
---|---|---|
error_message | String | A description of the error encountered |
status_code | Number | Status code for the HTTP request |
{
"error_message": "<errorMessage>",
"status_code": 400
}
Enroll Device
Enrolls the device with the Edge Manager.
POST
http://localhost/api/v1/host/enroll
Field | Type | Description |
---|---|---|
sharedSecret | String | Shared secret |
deviceId | String | Device identifier |
enrollmentUrl | String | URL for the enrollment |
curl http://localhost/api/v1/host/enroll \
--unix-socket /var/run/edge-core/edge-core.sock \
-X POST \
-H "Content-Type: application/json" \
-d '{
"sharedSecret": "secret",
"deviceId": "some-device-id",
"enrollmentUrl": "https://some-enrollment-url"
}'
Field | Type | Description |
---|---|---|
enrollment | String | "Certified enrollment success" |
{
"enrollment": "Certificate enrollment success"
}
Field | Type | Description |
---|---|---|
error_message | String | A description of the error encountered |
status_code | Number | The status code for the HTTP request |
{
"error_message": "<errorMessage>",
"status_code": 400
}
Get Enrollment Status
Gets enrollment details from the specified device.
GET
http://localhost/api/v1/host/enroll
curl http://localhost/api/v1/host/enroll \
--unix-socket /var/run/edge-core/edge-core.sock
Field | Type | Description |
---|---|---|
enrolled | Boolean | True if device is enrolled |
deviceId | String | Device identifier |
edgeManagerUrl | String | URL for the device manager |
{
"enrolled": true,
"deviceId": "some-device-id",
"edgeManagerUrl": "https://edgemanager-sysint.predix.io"
}
{
"enrolled": false
}
Logs
Get Log
Use journalctl to retrieve logs. The parameter descriptions reference sections in man journalctrl.
GET
http://localhost/api/v1/host/logs
Field | Type | Description |
---|---|---|
unit | String | Filter logs by the given UNIT (see --unit). |
priority | String | Filter the logs by priority (See --priority). |
useJSON | Boolean | Format output as JSON (See --output=json). |
useUTC | Boolean | Format timestamps in UTC time (See --utc). |
since | String | Filter logs before DATE (See --since). |
until | String | Filter logs after DATE (See --until). |
kernel | Boolean | Filter logs; only show kernel (See --kernel). |
boot | String | Filter out logs before the given boot (See --boot). |
applicationService | String | Filter logs on APPLICATION SERVICE. |
lines | Integer | Number of log lines to print. |
reverse | Boolean | Print the newest entries first. |
curl --unix-socket /var/run/edge-core/edge-core.sock \
http://localhost/api/v1/host/logs?since=1+hour+ago&useUTC=true
Field | Type | Description |
---|---|---|
log_text | String | Log content |
{
"log_text": "Nov 28 11:04:40 machine-name kernel: sd 2:0:0:0: [sda] \
Assuming drive cache: write through\\n"
}
Field | Type | Description |
---|---|---|
error_message | String | A description of the error encountered |
status_code | Number | The status code for the HTTP request |
{
"error_message": "<errorMessage>",
"status_code": 400
}
Network
Enable DHCP
Enables DHCP on a network interface.
PUT
http://localhost/api/v1/host/network/interfaces/<interface>/dhcp
Field | Type | Description |
---|---|---|
interface | String | Interface name |
curl --unix-socket /var/run/edge-core/edge-core.sock \
-X PUT http://localhost/api/v1/host/network/interfaces/enp0s3/dhcp
Field | Type | Description |
---|---|---|
dhcp | Boolean | Indicates if DHCP is used or not |
name | String | Interface name |
type | String | Interface type |
{
"dhcp": true,
"name": "enp0s3",
"type": "ethernet"
}
Field | Type | Description |
---|---|---|
error_message | String | A description of the error encountered |
status_code | Number | The status code for the HTTP request |
{
"error_message": "Invalid Interface",
"status_code": 400
}
Get NTP Information
Gets NTP information.
GET
http://localhost/api/v1/host/network/ntp
curl --unix-socket /var/run/edge-core/edge-core.sock \
http://localhost/api/v1/host/network/ntp
Field | Type | Description |
---|---|---|
server | String | NTP server IP address |
{
"servers": [
"192.168.233.228",
"ntp.ubuntu.com",
"time1.google.com"
]
}
Get Network Interface
Gets information for a specific network interface.
GET
http://localhost/api/v1/host/network/interfaces/<interface>
Field | Type | Description |
---|---|---|
interface | String | Name of the interface |
curl --unix-socket /var/run/edge-core/edge-core.sock \
http://localhost/api/v1/host/network/interfaces/enp0s3
Field | Type | Description |
---|---|---|
dhcp | Boolean | Indicates if DHCP is used or not |
dns | String | DNS server IP address |
gateway | String | Gateway IP address |
ipv4 | String | Interface IP address |
name | String | Interface name |
type | String | Interface type |
{
"dhcp": true,
"dns": "10.0.2.3,8.8.8.8",
"gateway": "10.0.2.2",
"ipv4": "10.0.2.15/24",
"name": "enp0s3",
"type": "ethernet"
}
Field | Type | Description |
---|---|---|
error_message | String | A description of the error encountered |
status_code | Number | The status code for the HTTP request |
{
"error_message": "<errorMessage>",
"status_code": 400
}
Get Network Interfaces
Gets information for the device’s network interfaces.
GET
http://localhost/api/v1/host/network/interfaces
curl --unix-socket /var/run/edge-core/edge-core.sock \
http://localhost/api/v1/host/network/interfaces
Field | Type | Description |
---|---|---|
interfaces | Object | List of interfaces |
dhcp | Boolean | Indicates if DHCP is used or not |
dns | String | DNS server IP address |
gateway | String | Gateway IP address |
ipv4 | String | Interface IP address |
name | String | Interface name |
type | String | Interface type |
{
"interfaces": [
{
"dhcp": true,
"dns": "10.0.2.3,8.8.8.8",
"gateway": "10.0.2.2",
"ipv4": "10.0.2.15/24",
"name": "enp0s3",
"type": "ethernet"
}
]
}
Get Proxy Information
Gets network proxy information.
GET
http://localhost/api/v1/host/network/proxy
curl --unix-socket /var/run/edge-core/edge-core.sock \
http://localhost/api/v1/host/network/proxy
Field | Type | Description |
---|---|---|
http | String | HTTP proxy IP address |
https | String | HTTPS proxy IP address |
no_proxy | String | Non-proxy servers |
{
"http": "http://3.3.3.3:80",
"https": "http://5.5.5.5:88",
"no_proxy": "*.ge.com, *.google.com"
}
Set NTP Information
Sets the NTP server address.
PUT
http://localhost/api/v1/host/network/ntp
Field | Type | Description |
---|---|---|
server | String | IP address of an NTP server |
curl http://localhost/api/v1/host/network/ntp \
--unix-socket /var/run/edge-core/edge-core.sock \
-X PUT \
-H "Content-Type: application/json" \
-d '{
"servers" : ["192.168.233.228", "ntp.ubuntu.com", "time1.google.com"]
}'
Field | Type | Description |
---|---|---|
server | String | IP address of an NTP server |
{
"servers": [
"192.168.233.228",
"ntp.ubuntu.com",
"time1.google.com"
]
}
Field | Type | Description |
---|---|---|
error_message | String | A description of the error encountered |
status_code | Number | The status code for the HTTP request |
{
"error_message": "<errorMessage>",
"status_code": 400
}
Set Network Interface
Manually configures a network interface.
PUT
http://localhost/api/v1/host/network/interfaces/<interface>/manual
Field | Type | Description |
---|---|---|
ipv4 | String | Network interface IP address |
gateway | String | Gateway IP address |
dns | String | DNS server IP address |
curl http://localhost/api/v1/host/network/interfaces/enp0s3/manual \
--unix-socket /var/run/edge-core/edge-core.sock \
-X PUT \
-H "Content-Type: application/json" \
-d '{
"ipv4": "192.168.233.228/24",
"gateway": "192.168.233.2",
"dns": "192.168.233.2"
}'
Field | Type | Description |
---|---|---|
dhcp | Boolean | Indicates if DHCP is used or not |
dns | String | DNS server IP address |
gateway | String | Gateway server IP address |
ipv4 | String | IP network interface address |
name | String | Network interface name |
type | String | Network interface type |
Field | Type | Description |
---|---|---|
error_message | String | A description of the error encountered |
status_code | Number | The status code for the HTTP request |
{
"error_message": "<errorMessage>",
"status_code": 400
}
Set Proxy Information
Sets network proxy information. A reboot is required for the new proxy setting(s) to take effect. All running Edge applications will be redeployed automatically during the next reboot to pickup the new proxy values.
PUT
http://localhost/api/v1/host/network/proxy
Field | Type | Description |
---|---|---|
http | String | HTTP proxy IP address |
https | String | HTTPS proxy IP address |
no_proxy | String | Non-proxy servers |
curl http://localhost/api/v1/host/network/proxy \
--unix-socket /var/run/edge-core/edge-core.sock \
-X PUT \
-H "Content-Type: application/json" \
-d '{
"http" : "http://192.168.223.228:80",
"https" : "http://192.168.233.229:80",
"no_proxy": "google.com"
}'
Field | Type | Description |
---|---|---|
proxy | String | "Proxy set successfully" |
{
"proxy": "Proxy set successfully"
}
Field | Type | Description |
---|---|---|
error_message | String | A description of the error encountered |
status_code | Number | The status code for the HTTP request |
{
"error_message": "<errorMessage>",
"status_code": 400
}