Api >

Service Portal REST API

POST creates Base Device with Configuration data
Given I am authenticated as K0002
and there is a Base Device type
and there is firmware with name 01.49
When I send /api/customers/K0002/devices/base as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "mac",
    "value": "ABCDEF012345"
  }, {
    "name": "webguiHttpsonly",
    "value": true
  }, {
    "name": "suppressLineno",
    "value": "DEFAULT"
  }, {
    "name": "note",
    "value": "my personal note on post request"
  }],
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/Base%20Device"
  }]
}
Then I should receive HTTP/1.1 201 Created
{
  "href": "/api/customers/K0002/devices/base/ABCDEF012345"
}
Given I am authenticated as K0002
Then request /api/customers/K0002/devices/base/ABCDEF012345 should return:
{
  "href": "/api/customers/K0002/devices/base/ABCDEF012345",
  "data": [{
    "name": "mac",
    "value": "ABCDEF012345"
  }, {
    "name": "suppressLineno",
    "value": "DEFAULT"
  }, {
    "name": "webguiHttpsonly",
    "value": true
  }, {
    "name": "note",
    "value": "my personal note on post request"
  }],
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/Base%20Device"
  }]
}
POST creates Extended Base Device with Configuration data
Given I am authenticated as K0002
And there is a ExtendedBaseDevice type
When I send /api/customers/K0002/devices/base as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "mac",
    "value": "ABCDEF012345"
  }],
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/ExtendedBaseDevice"
  }]
}
Then I should receive HTTP/1.1 201 Created
{
  "href": "/api/customers/K0002/devices/base/ABCDEF012345"
}
Given I am authenticated as K0002
Then request /api/customers/K0002/devices/base/ABCDEF012345 should return:
{
  "href": "/api/customers/K0002/devices/base/ABCDEF012345",
  "data": [{
    "name": "mac",
    "value": "ABCDEF012345"
  }],
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/ExtendedBaseDevice"
  }]
}
POST does not create Base Device with device type of master category other than BASE
Given I am authenticated as K0002
and there is a Handset type
When I send /api/customers/K0002/devices/base as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "mac",
    "value": "ABCDEF012345"
  }],
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/Handset"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
{
  "title": "Validation error",
  "detail": "Could not create or update resource due to constraint violations",
  "errors": [{
    "message": "Cannot create Base Device with type that is not of BASE or EXTENDEDBASE category",
    "path": "deviceType",
    "value": "/api/customers/K0002/device-types/Handset"
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
POST creates Base Device with links
Given I am authenticated as K0002
and there is a BaseDevice type
and there is a 150.123 Firmware
and there is a a062000000HbAsd Site
When I send /api/customers/K0002/devices/base as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/BaseDevice"
  }, {
    "rel": "firmware",
    "href": "/api/customers/K0002/device-types/BaseDevice/firmwares/150.123"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/a062000000HbAsd"
  }],
  "data": [{
    "name": "mac",
    "value": "ABCDEF012345"
  }]
}
Then I should receive HTTP/1.1 201 Created
{
  "href": "/api/customers/K0002/devices/base/ABCDEF012345"
}
Given I am authenticated as K0002
Then request /api/customers/K0002/devices/base/ABCDEF012345 should return:
{
  "links": [{
    "rel": "firmware",
    "href": "/api/customers/K0002/device-types/BaseDevice/firmwares/150.123"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/a062000000HbAsd"
  }]
}
POST creates Base Device with DHCP data
Given I am authenticated as K0002
and there is a BaseDevice type
When I send /api/customers/K0002/devices/base as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/BaseDevice"
  }],
  "data": [{
    "name": "mac",
    "value": "ABCDEF012345"
  }, {
    "name": "dhcpEnabled",
    "value": false
  }, {
    "name": "ipAddress",
    "value": "192.168.64.1"
  }, {
    "name": "netmask",
    "value": "192.168.64.2"
  }, {
    "name": "gateway",
    "value": "192.168.64.3"
  }, {
    "name": "dns1",
    "value": "192.168.64.4"
  }, {
    "name": "dns2",
    "value": "192.168.64.5"
  }, {
    "name": "mtu",
    "value": "1500"
  }]
}
Then I should receive HTTP/1.1 201 Created
{
  "href": "/api/customers/K0002/devices/base/ABCDEF012345"
}
Given I am authenticated as K0002
Then request /api/customers/K0002/devices/base/ABCDEF012345 should return:
{
  "data": [{
    "name": "dhcpEnabled",
    "value": false
  }, {
    "name": "ipAddress",
    "value": "192.168.64.1"
  }, {
    "name": "netmask",
    "value": "192.168.64.2"
  }, {
    "name": "gateway",
    "value": "192.168.64.3"
  }, {
    "name": "dns1",
    "value": "192.168.64.4"
  }, {
    "name": "dns2",
    "value": "192.168.64.5"
  }, {
    "name": "mtu",
    "value": "1500"
  }]
}
POST does not create Base Device if dhcpEnabled is not false
Given I am authenticated as K0002
and there is a BaseDevice type
When I send /api/customers/K0002/devices/base as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/BaseDevice"
  }],
  "data": [{
    "name": "mac",
    "value": "ABCDEF012345"
  }, {
    "name": "ipAddress",
    "value": "192.168.64.1"
  }, {
    "name": "netmask",
    "value": "192.168.64.2"
  }, {
    "name": "gateway",
    "value": "192.168.64.3"
  }, {
    "name": "dns1",
    "value": "192.168.64.4"
  }, {
    "name": "dns2",
    "value": "192.168.64.5"
  }, {
    "name": "mtu",
    "value": "1500"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
{
  "title": "Validation error",
  "detail": "Could not create or update resource due to constraint violations",
  "errors": [{
    "message": "Cannot set DHCP options if dhcpEnabled is not false",
    "path": "dhcpEnabled"
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
POST does not create Base Device if required properties are not provided
Given I am authenticated as K0002
and there is a BaseDevice type
When I send /api/customers/K0002/devices/base as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/BaseDevice"
  }],
  "data": [{
    "name": "mac",
    "value": "ABCDEF012345"
  }, {
    "name": "dhcpEnabled",
    "value": false
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
{
  "title": "Validation error",
  "detail": "Could not create or update resource due to constraint violations",
  "errors": [{
    "message": "The following fields are required if dhcpEnabled is not false: ipAddress, netmask, gateway, mtu"
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
POST does not create Base Device if ipAddress is not in IP format
Given I am authenticated as K0002
and there is a BaseDevice type
When I send /api/customers/K0002/devices/base as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/BaseDevice"
  }],
  "data": [{
    "name": "mac",
    "value": "ABCDEF012345"
  }, {
    "name": "dhcpEnabled",
    "value": false
  }, {
    "name": "ipAddress",
    "value": "192.168.64.1.what?"
  }, {
    "name": "netmask",
    "value": "192.168.64.2"
  }, {
    "name": "gateway",
    "value": "192.168.64.3"
  }, {
    "name": "mtu",
    "value": "1500"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
{
  "title": "Validation error",
  "detail": "Could not create or update resource due to constraint violations",
  "errors": [{
    "message": "ipAddress is not in IP format",
    "value": "192.168.64.1.what?"
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
POST does not create Base Device if invalid mtu is provided
Given I am authenticated as K0002
and there is a BaseDevice type
When I send /api/customers/K0002/devices/base as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/BaseDevice"
  }],
  "data": [{
    "name": "mac",
    "value": "ABCDEF012345"
  }, {
    "name": "dhcpEnabled",
    "value": false
  }, {
    "name": "ipAddress",
    "value": "192.168.64.1"
  }, {
    "name": "netmask",
    "value": "192.168.64.2"
  }, {
    "name": "gateway",
    "value": "192.168.64.3"
  }, {
    "name": "mtu",
    "value": "123"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
{
  "title": "Validation error",
  "detail": "Could not create or update resource due to constraint violations",
  "errors": [{
    "message": "mtu must be one of: [\"1500\", \"9000\"]",
    "path": "mtu",
    "value": "123"
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
POST creates Base Device with Customer's dummy site if none is provided
Given I am authenticated as K0002
and there is a BaseDevice type
When I send /api/customers/K0002/devices/base as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/BaseDevice"
  }],
  "data": [{
    "name": "mac",
    "value": "ABCDEF012345"
  }]
}
Then I should receive HTTP/1.1 201 Created
{
  "href": "/api/customers/K0002/devices/base/ABCDEF012345"
}
Given I am authenticated as K0002
Then request /api/customers/K0002/devices/base/ABCDEF012345 should return:
{
  "href": "/api/customers/K0002/devices/base/ABCDEF012345",
  "links": [{
    "rel": "site",
    "href": "/api/customers/K0002/sites/1"
  }]
}
POST creates Base Device with Device Type's preferred firmware if none is provided
Given I am authenticated as K0002
and there is a BaseDevice type with preferred firmware 1.2.13
When I send /api/customers/K0002/devices/base as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/BaseDevice"
  }],
  "data": [{
    "name": "mac",
    "value": "ABCDEF012345"
  }]
}
Then I should receive HTTP/1.1 201 Created
{
  "href": "/api/customers/K0002/devices/base/ABCDEF012345"
}
Given I am authenticated as K0002
Then request /api/customers/K0002/devices/base/ABCDEF012345 should return:
{
  "href": "/api/customers/K0002/devices/base/ABCDEF012345",
  "links": [{
    "rel": "firmware",
    "href": "/api/customers/K0002/device-types/BaseDevice/firmwares/1.2.13"
  }]
}
POST creates Patton Base Device with bitrate option
Given I am authenticated as K0002
and there is a BaseDevice type with device category Patton and Port Type PORT
When I send /api/customers/K0002/devices/base as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/BaseDevice"
  }],
  "data": [{
    "name": "mac",
    "value": "ABCDEF012345"
  }, {
    "name": "bitrate",
    "value": "7200"
  }]
}
Then I should receive HTTP/1.1 201 Created
{
  "href": "/api/customers/K0002/devices/base/ABCDEF012345"
}
Given I am authenticated as K0002
Then request /api/customers/K0002/devices/base/ABCDEF012345 should return:
{
  "href": "/api/customers/K0002/devices/base/ABCDEF012345",
  "data": [{
    "name": "bitrate",
    "value": "7200"
  }]
}
POST does not create Patton Base Device with invalid bitrate value
Given I am authenticated as K0002
and there is a BaseDevice type with device category Patton
and Port Type PORT
When I send /api/customers/K0002/devices/base as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/BaseDevice"
  }],
  "data": [{
    "name": "mac",
    "value": "ABCDEF012345"
  }, {
    "name": "bitrate",
    "value": "abc"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
{
  "title": "Validation error",
  "detail": "Could not create or update resource due to constraint violations",
  "errors": [{
    "message": "bitrate must be one of: [\"-\", \"2400\", \"4800\", \"7200\", \"9600\", \"12000\", \"14400\"]",
    "path": "bitrate",
    "value": "abc"
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
POST does not create non-Patton Base Device with bitrate option
Given I am authenticated as K0002
and there is a BaseDevice type with device category Kirk
and Port Type IPEI
When I send /api/customers/K0002/devices/base as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/BaseDevice"
  }],
  "data": [{
    "name": "mac",
    "value": "ABCDEF012345"
  }, {
    "name": "bitrate",
    "value": "7200"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
{
  "title": "Validation error",
  "detail": "Could not create or update resource due to constraint violations",
  "errors": [{
    "message": "bitrate is only available for Patton bases",
    "path": "bitrate"
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
POST does not create Base Device with empty mac
Given I am authenticated as K0002
and there is a BaseDevice
When I send /api/customers/K0002/devices/base as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/BaseDevice"
  }],
  "data": [{
    "name": "mac",
    "value": ""
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
{
  "title": "Validation error",
  "detail": "Could not create or update resource due to constraint violations",
  "errors": [{
    "message": "MAC number not defined",
    "path": "uniqueIdentifier"
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
POST does not create Base Device with invalid MAC
Given I am authenticated as K0002
and there is a BaseDevice
When I send /api/customers/K0002/devices/base as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/BaseDevice"
  }],
  "data": [{
    "name": "mac",
    "value": "acbdefghijkl"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
{
  "title": "Validation error",
  "detail": "Could not create or update resource due to constraint violations",
  "errors": [{
    "message": "MAC number not valid",
    "path": "uniqueIdentifier"
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
POST does not create Base Device with duplicated MAC
Given I am authenticated as K0002
and there is a BaseDevice and there is already a device with MAC ABCDEF012345
When I send /api/customers/K0002/devices/base as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/BaseDevice"
  }],
  "data": [{
    "name": "mac",
    "value": "ABCDEF012345"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
{
  "title": "Validation error",
  "detail": "Could not create or update resource due to constraint violations",
  "errors": [{
    "message": "MAC number not unique",
    "path": "uniqueIdentifier"
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
Cannot create Base Device if it will break Customer's Contract constraints
Given I am authenticated as customer K0003 And there is a BaseDevice type
and my Contract does not allow me to add more Devices
When I send /api/customers/K0003/devices/base as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "mac",
    "value": "ABCDEF012345"
  }],
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0003/device-types/BaseDevice"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request with following body:
{
  "errors": [{
    "message": "Customer contract type does not allow to add more Devices"
  }]
}
Cannot create Device with not existing Device Type
Given I am authenticated as customer K0002
When I send /api/customers/K0002/devices/base with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/not-existing"
  }],
  "data": [{
    "name": "mac",
    "value": "ABCDEF012345"
  }]
}
Then I should receive HTTP/1.1 404 Not Found
with following body:
{
  "title": "Device Type not found",
  "detail": "Device Type with name not-existing not found",
  "described_by": "http://api.nfon.net/probs/device-type-not-found"
}
Admin Cannot create Device with missing Customer
Given I am authenticated as Admin
And there is a BaseDevice type
When I send /api/customers/K0404/devices/base with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/not-existing"
  }],
  "data": [{
    "name": "mac",
    "value": "ABCDEF012345"
  }]
}
Then I should receive HTTP/1.1 404 Not Found
with following body:
{
  "title": "Customer not found",
  "detail": "Customer with identifier K0404 has not been found",
  "described_by": "http://api.nfon.net/probs/customer-not-found"
}
Cannot create Base Device for another Customer
and I am authenticated as K0003
And there is a BaseDevice type
When I send /api/customers/K0002/devices/base with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0002/device-types/not-existing"
  }],
  "data": [{
    "name": "mac",
    "value": "ABCDEF012345"
  }]
}
Then I should get HTTP/1.1 403 Forbidden
{
  "title": "Access forbidden",
  "detail": "Access denied to [Customer] with id [K0002]",
  "described_by": "http://api.nfon.net/probs/invalid-authorization"
}
System Integrator cannot create Base Device for Customer that does not belong to him
Given I am authenticated as System Integrator S0002
When I send /api/customers/K0003/devices/base with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0003/device-types/type01"
  }],
  "data": [{
    "name": "mac",
    "value": "ABCDEF012345"
  }]
}
Then I should receive HTTP/1.1 403 Forbidden
with following body
{
  "title": "Access forbidden",
  "detail": "Access denied to [Customer] with id [K0003]",
  "described_by": "http://api.nfon.net/probs/invalid-authorization"
}
Operator cannot cannot create Base Device for Customer that does not belong to him
Given I am authenticated as Operator C0002
When I send /api/customers/K0003/devices/base with application/json; charset=UTF-8
and following body:
{
  "links": [{
    "rel": "deviceType",
    "href": "/api/customers/K0003/device-types/type01"
  }],
  "data": [{
    "name": "mac",
    "value": "ABCDEF012345"
  }]
}
Then I should receive HTTP/1.1 403 Forbidden
with following body
{
  "title": "Access forbidden",
  "detail": "Access denied to [Customer] with id [K0003]",
  "described_by": "http://api.nfon.net/probs/invalid-authorization"
}