Api >

Service Portal REST API

PUT updates Base Device with links
Given I am authenticated as K0002
and there is a BaseDevice with MAC ABCDEF012345
and there is a 150.123 Firmware
and there is a a062000000HbAsd Site
When I send /api/customers/K0002/devices/base/ABCDEF012345 as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "firmware",
    "href": "/api/customers/K0002/device-types/BaseDevice/firmwares/150.123"
  }, {
    "rel": "site",
    "href": "/api/customers/K0002/sites/a062000000HbAsd"
  }]
}
Then I should receive HTTP/1.1 204 No Content
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"
  }]
}
PUT updates Base Device note property
Given I am authenticated as K0002
and there is a BaseDevice with MAC ABCDEF012345 When I send /api/customers/K0002/devices/base/ABCDEF012345 with application/json; charset=UTF-8
and following body:
{
  "data": [{
    "name": "note",
    "value": "my personal note for this device"
  }]
}
Then I should receive HTTP/1.1 204 No Content

Given I am authenticated as customer K0002
When I send /api/customers/K0002/devices/base/ABCDEF012345
Then I should receive HTTP/1.1 200 OK
with following body:
{
  "data": [{
    "name": "note",
    "value": "my personal note for this device"
  }]
}
PUT deletes Base Device note property if empty value is given
Given I am authenticated as K0002
and there is a BaseDevice with MAC ABCDEF012345 When I send /api/customers/K0002/devices/base/ABCDEF012345 with application/json; charset=UTF-8
and following body:
{
  "data": [{
    "name": "note",
    "value": ""
  }]
}
Then I should receive HTTP/1.1 204 No Content

Given I am authenticated as customer K0002
When I send /api/customers/K0002/devices/base/ABCDEF012345
Then I should receive HTTP/1.1 200 OK
with following body:
{
  "data": [{
    "name": "note",
    "value": null
  }]
}
PUT deletes Base Device note property if null value is given
Given I am authenticated as K0002
and there is a BaseDevice with MAC ABCDEF012345 When I send /api/customers/K0002/devices/base/ABCDEF012345 with application/json; charset=UTF-8
and following body:
{
  "data": [{
    "name": "note",
    "value": null
  }]
}
Then I should receive HTTP/1.1 204 No Content

Given I am authenticated as customer K0002
When I send /api/customers/K0002/devices/base/ABCDEF012345
Then I should receive HTTP/1.1 200 OK
with following body:
{
  "data": [{
    "name": "note",
    "value": null
  }]
}
PUT updates Base Device with DHCP data
Given I am authenticated as K0002
and there is a BaseDevice with MAC ABCDEF012345 and following DHCP options:
  • IP Address 192.168.1.150
  • Netmask 255.255.255.0
  • Gateway 192.168.1.1
  • DNS1 8.8.8.8
  • DNS2 10.10.10.10
  • MTU 1500
When I send /api/customers/K0002/devices/base/ABCDEF012345 as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "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": "9000"
  }, {
    "name": "webguiHttpsonly",
    "value": true
  }, {
    "name": "suppressLineno",
    "value": "DEFAULT"
  }]
}
Then I should receive HTTP/1.1 204 No Content
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": "9000"
  }, {
    "name": "suppressLineno",
    "value": "DEFAULT"
  }]
}
PUT does not update Base Device if dhcpEnabled is not false
Given I am authenticated as K0002
and there is a BaseDevice with MAC ABCDEF012345 and no DHCP options
When I send /api/customers/K0002/devices/base/ABCDEF012345 as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "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"
}
PUT does not update Base Device if ipAddress is not in IP format
Given I am authenticated as K0002
and there is a BaseDevice with MAC ABCDEF012345 and following DHCP options:
  • IP Address 192.168.1.150
  • Netmask 255.255.255.0
  • Gateway 192.168.1.1
  • DNS1 8.8.8.8
  • DNS2 10.10.10.10
  • MTU 1500

When I send /api/customers/K0002/devices/base/ABCDEF012345 as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "ipAddress",
    "value": "192.168.64.1.what?"
  }]
}
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"
}
PUT does not update Base Device if invalid mtu is provided
Given I am authenticated as K0002
and there is a BaseDevice with MAC ABCDEF012345 and following DHCP options:
  • IP Address 192.168.1.150
  • Netmask 255.255.255.0
  • Gateway 192.168.1.1
  • DNS1 8.8.8.8
  • DNS2 10.10.10.10
  • MTU 1500

When I send /api/customers/K0002/devices/base/ABCDEF012345 as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "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\"]"
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
PUT removes Base Device's DHCP options if dhcpEnabled is set to true
Given I am authenticated as K0002
and there is a BaseDevice with MAC ABCDEF012345 and following DHCP options:
  • IP Address 192.168.1.150
  • Netmask 255.255.255.0
  • Gateway 192.168.1.1
  • DNS1 8.8.8.8
  • DNS2 10.10.10.10
  • MTU 1500

When I send /api/customers/K0002/devices/base/ABCDEF012345 as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "dhcpEnabled",
    "value": true
  }]
}
Then I should receive HTTP/1.1 204 No Content
Given I am authenticated as K0002
Then request /api/customers/K0002/devices/base/ABCDEF012345 should return:
{
  "data": [{
    "name": "dhcpEnabled",
    "value": true
  }, {
    "name": "ipAddress",
    "value": null
  }, {
    "name": "netmask",
    "value": null
  }, {
    "name": "gateway",
    "value": null
  }, {
    "name": "dns1",
    "value": null
  }, {
    "name": "dns2",
    "value": null
  }, {
    "name": "mtu",
    "value": null
  }]
}
PUT does not update Base Device's DHCP options when dhcpEnabled is changed to true
Given I am authenticated as K0002
and there is a BaseDevice with MAC ABCDEF012345 and following DHCP options:
  • IP Address 192.168.1.150
  • Netmask 255.255.255.0
  • Gateway 192.168.1.1
  • DNS1 8.8.8.8
  • DNS2 10.10.10.10
  • MTU 1500

When I send /api/customers/K0002/devices/base/ABCDEF012345 as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "dhcpEnabled",
    "value": true
  }, {
    "name": "ipAddress",
    "value": "192.168.64.1"
  }, {
    "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 with following body:
{
  "errors": [{
    "message": "Cannot set DHCP options if dhcpEnabled is not false",
    "path": "dhcpEnabled"
  }]
}
PUT updates Patton Base Device's bitrate
Given I am authenticated as K0002
and there is a Patton BaseDevice with MAC ABCDEF012345 and bitrate 12000
and Port Type PORT
When I send /api/customers/K0002/devices/base/ABCDEF012345 as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "bitrate",
    "value": "4800"
  }]
}
Then I should receive HTTP/1.1 204 No Content
and authenticated call to /api/customers/K0002/devices/base/ABCDEF012345 should return:
{
  "data": [{
    "name": "bitrate",
    "value": "4800"
  }]
}
PUT does not update non-Patton Base Device's bitrate
Given I am authenticated as K0002
and there is a Kirk BaseDevice with MAC ABCDEF012345
and Port Type IPEI
When I send /api/customers/K0002/devices/base/ABCDEF012345 as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "bitrate",
    "value": "4800"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request with following body:
{
  "errors": [{
    "message": "bitrate is only available for Patton bases",
    "path": "bitrate"
  }]
}
PUT does not update Base Device's firmware, if it doesn't fit Device Type
Given I am authenticated as K0002
and there is a BaseDevice with MAC ABCDEF012345 and there is a 150.123 Firmware for OtherBaseDeviceType
When I send /api/customers/K0002/devices/base/ABCDEF012345 as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "firmware",
    "href": "/api/customers/K0002/device-types/OtherBaseDeviceType/firmwares/150.123"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request with following body:
{
  "errors": [{
    "message": "Firmware is invalid for selected device type",
    "detailMessage": "Provided firmware with releaseVersion 150.123 is invalid for device with type BaseDevice",
    "path": "firmware"
  }]
}
PUT does not update Base Device's site, if it is not accessible by the Customer
Given I am authenticated as Admin
and there is a BaseDevice with MAC ABCDEF012345 and there is a a062000000K0003 Site that belongs to Customer K0003 When I send /api/customers/K0002/devices/base/ABCDEF012345 as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "site",
    "href": "/api/customers/K0003/sites/a062000000K0003"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request with following body:
{
  "errors": [{
    "message": "Site not allowed",
    "detailMessage": "Site [a062000000K0003] is not reachable for customer [K0002]",
    "path": "site"
  }]
}
System Integrator cannot update Base Device of Customer that does not belong to him
Given I am authenticated as System Integrator S0002
When I send /api/customers/K0003/devices/base/ABCDEF012345 as application/json; charset=UTF-8 with following body:
{}
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 update Base Device of Customer that does not belong to him
Given I am authenticated as Operator C0002
When I send /api/customers/K0003/devices/base/ABCDEF012345 as application/json; charset=UTF-8 with following body:
{}
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"
}