Client - Server API¶
URL Endpoints¶
HTTP Method | URI |
---|---|
GET | /bootstrap/config |
GET | /bootstrap |
POST | /nodes |
PUT | /nodes/{id} |
GET | /nodes/{id} |
GET | /actions/{name} |
GET | /files/{filepath} |
GET bootstrap script¶
- GET /bootstrap¶
Returns the default bootstrap script
Response
Status: 200 OK Content-Type: text/x-python
Note
For every request, the bootstrap controller on the ZTPServer will attempt to perform the following string replacement in the bootstrap script): “$SERVER“ —> the value of the “server_url” variable in the server’s configuration file This string-replacement will point the bootstrap client back to the server, in order to enable it to make additional requests for further resources.
- if the server_url variable is missing in the server’s configuration file, ‘http://ztpserver:8080‘ is used by default
- if the $SERVER string does not exist in the bootstrap script, the controller will log a warning message and continue
GET logging configuration¶
- GET /bootstrap/config¶
Returns the logging configuration from the server.
Request
GET /bootstrap/config HTTP/1.1 Host: Accept: Content-Type: text/html
Response
Status: 200 OK Content-Type: application/json { “logging”*: [ { “destination”: “file:/<PATH>” | “<HOSTNAME OR IP>:<PORT>”, //localhost enabled //by default “level”*: <DEBUG | CRITICAL | ...>, } ] }, “xmpp”*:{ “server”: <IP or HOSTNAME>, “port”: <PORT>, // Optional, default 5222 “username”*: <USERNAME>, “domain”*: <DOMAIN>, “password”*: <PASSWORD>, “nickname”: <NICKNAME>, // Optional, default ‘username’ “rooms”*: [ <ROOM>, … ] } } }
Note: * Items are mandatory (even if value is empty list/dict)
POST node details¶
Send node information to the server in order to check whether it can be provisioned.
- POST /nodes¶
Request
Content-Type: application/json { “model”*: <MODEL_NAME>, “serialnumber”*: <SERIAL_NUMBER>, “systemmac”*: <SYSTEM_MAC>, “version”*: <INTERNAL_VERSION>, “neighbors”*: { <INTERFACE_NAME(LOCAL)>: [ { 'device': <DEVICE_NAME>, 'remote_interface': <INTERFACE_NAME(REMOTE)> } ] }, }
Note: * Items are mandatory (even if value is empty list/dict)
Response
Status: 201 Created Content-Type: text/html Location: <url> Status: 409 Conflict Content-Type: text/html Location: <url> Status: 400 Bad Request Content-Type: text/html
Status Codes: - 201 Created – Created
- 409 Conflict – Conflict
- 400 Bad Request – Bad Request
GET node definition¶
Request definition from the server.
- GET /nodes/(ID)¶
Request
GET /nodes/{ID} HTTP/1.1 Host: Accept: applicatino/json Content-Type: text/html
Response
Status: 200 OK Content-Type: application/json { “name”*: <DEFINITION_NAME> “actions”*: [{ “action”*: <NAME>*, “description”: <DESCRIPTION>, “onstart”: <MESSAGE>, “onsuccess”: <MESSAGE>, “onfailure”: <MESSAGE>, “always_execute”: [True, False], “attributes”: { <KEY>: <VALUE>, <KEY>: { <KEY> : <VALUE>}, <KEY>: [ <VALUE>, <VALUE> ] } },...] }
Note: * Items are mandatory (even if value is empty list/dict)
Status Codes: - 400 Bad Request – Bad Request
- 404 Not Found – Not Found
GET action¶
- GET /actions/(NAME)¶
I Request action from the server.
Request
Content-Type: text/htmlResponse
Content-Type: text/x-python
statuscode 200: OK statuscode 400: Bad Request statuscode 404: Not Found Status: 200 OK Content-Type: text/plain <PYTHON SCRIPT>
Status: 200 Bad request Content-Type: text/x-python
GET resource¶
- GET /files/(RESOURCE_PATH)¶
Request action from the server.
Request
Content-Type: text/html
Response
Status: 200 OK Content-Type: text/plain <resource>
Status Codes: - 200 OK – OK
- 404 Not Found – Not Found