Api >

Service Portal REST API

Admin can create Sip Server
Given I am authenticated as Admin
and there is a Pbx Group with name Pbx1
And next Sip Server ID will be 200
When I send /api/sip-servers
with application/json; charset=UTF-8 and following body:
{
  "links": [{
    "rel": "pbxGroup",
    "href": "/api/pbx-groups/Pbx1"
  }],
  "data": [{
    "name": "name",
    "value": "sipServerName"
  }, {
    "name": "externalIp",
    "value": "192.168.1.1"
  }, {
    "name": "internalIp",
    "value": "192.168.1.2"
  }, {
    "name": "maxSubscribers",
    "value": 1000
  }, {
    "name": "subscribersLimit",
    "value": 500
  }, {
    "name": "location",
    "value": "Location"
  }, {
    "name": "partition",
    "value": "P01"
  }, {
    "name": "description",
    "value": "4xE5504-2GHZ;4GB"
  }]
}
Then I should receive HTTP/1.1 201 Created
with http://localhost:9998/api/sip-servers/200 and following body:
{
  "href": "/api/sip-servers/200"
}

Given I am authenticated as Admin
When I send /api/sip-servers/200
Then I should receive HTTP/1.1 200 OK
with body:
{
  "href": "/api/sip-servers/200",
  "links": [{
    "rel": "pbxGroup",
    "href": "/api/pbx-groups/Pbx1"
  }, {
    "rel": "availablePbxGroup",
    "href": "/api/pbx-groups"
  }],
  "data": [{
    "name": "name",
    "value": "sipServerName"
  }, {
    "name": "externalIp",
    "value": "192.168.1.1"
  }, {
    "name": "internalIp",
    "value": "192.168.1.2"
  }, {
    "name": "maxSubscribers",
    "value": 1000
  }, {
    "name": "subscribersLimit",
    "value": 500
  }, {
    "name": "location",
    "value": "Location"
  }, {
    "name": "partition",
    "value": "P01"
  }, {
    "name": "description",
    "value": "4xE5504-2GHZ;4GB"
  }]
}
Admin can create Sip Server with only required data
Given I am authenticated as Admin
and there is a Pbx Group with name Pbx1
And next Sip Server ID will be 200
When I send /api/sip-servers
with application/json; charset=UTF-8 and following body:
{
  "links": [{
    "rel": "pbxGroup",
    "href": "/api/pbx-groups/Pbx1"
  }],
  "data": [{
    "name": "name",
    "value": "sipServerName"
  }, {
    "name": "externalIp",
    "value": "192.168.1.1"
  }, {
    "name": "internalIp",
    "value": "192.168.1.2"
  }, {
    "name": "subscribersLimit",
    "value": 500
  }, {
    "name": "partition",
    "value": "P01"
  }]
}
Then I should receive HTTP/1.1 201 Created
with http://localhost:9998/api/sip-servers/200 and following body:
{
  "href": "/api/sip-servers/200"
}

Given I am authenticated as Admin
When I send /api/sip-servers/200
Then I should receive HTTP/1.1 200 OK
with body:
{
  "links": [{
    "rel": "pbxGroup",
    "href": "/api/pbx-groups/Pbx1"
  }],
  "data": [{
    "name": "name",
    "value": "sipServerName"
  }, {
    "name": "externalIp",
    "value": "192.168.1.1"
  }, {
    "name": "internalIp",
    "value": "192.168.1.2"
  }, {
    "name": "subscribersLimit",
    "value": 500
  }, {
    "name": "partition",
    "value": "P01"
  }]
}
Admin cannot create Sip Server if maxSubscribers has incorrect value
Given I am authenticated as Admin
and there is a Pbx Group with name Pbx1
When I send /api/sip-servers
with application/json; charset=UTF-8 and following body:
{
  "links": [{
    "rel": "pbxGroup",
    "href": "/api/pbx-groups/Pbx1"
  }],
  "data": [{
    "name": "name",
    "value": "sipServerName"
  }, {
    "name": "externalIp",
    "value": "192.168.1.1"
  }, {
    "name": "internalIp",
    "value": "192.168.1.2"
  }, {
    "name": "maxSubscribers",
    "value": -10000000
  }, {
    "name": "subscribersLimit",
    "value": 500
  }, {
    "name": "partition",
    "value": "P01"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
and following body:
{
  "errors": [{
    "message": "maxSubscribers must be greater than or equal -10000",
    "path": "maxSubscribers",
    "value": -10000000
  }]
}
Admin cannot create Sip Server if subscribersLimit has incorrect value
Given I am authenticated as Admin
and there is a Pbx Group with name Pbx1
And next Sip Server ID will be 200
When I send /api/sip-servers
with application/json; charset=UTF-8 and following body:
{
  "links": [{
    "rel": "pbxGroup",
    "href": "/api/pbx-groups/Pbx1"
  }],
  "data": [{
    "name": "name",
    "value": "sipServerName"
  }, {
    "name": "externalIp",
    "value": "192.168.1.1"
  }, {
    "name": "internalIp",
    "value": "192.168.1.2"
  }, {
    "name": "subscribersLimit",
    "value": 0
  }, {
    "name": "partition",
    "value": "P01"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
and following body:
{
  "errors": [{
    "message": "subscribersLimit must be greater than 0",
    "path": "subscribersLimit",
    "value": 0
  }]
}
Admin cannot create Sip Server if name is not unique
Given I am authenticated as Admin
and there is a Pbx Group with name Pbx1
And there is a Sip Server with name: sipServerName
When I send /api/sip-servers
with application/json; charset=UTF-8 and following body:
{
  "links": [{
    "rel": "pbxGroup",
    "href": "/api/pbx-groups/Pbx1"
  }],
  "data": [{
    "name": "name",
    "value": "sipServerName"
  }, {
    "name": "externalIp",
    "value": "192.168.1.1"
  }, {
    "name": "internalIp",
    "value": "192.168.1.2"
  }, {
    "name": "subscribersLimit",
    "value": 500
  }, {
    "name": "partition",
    "value": "P01"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
and following body:
{
  "errors": [{
    "message": "name is not unique",
    "path": "name",
    "value": "sipServerName"
  }]
}
Admin cannot create Sip Server if pbxGroup has invalid value - belongs to different endpoint
Given I am authenticated as Admin
and there is a Pbx Group with name Pbx1 which is assigned to Operator C0002
When I send /api/sip-servers
with application/json; charset=UTF-8 and following body:
{
  "links": [{
    "rel": "pbxGroup",
    "href": "/api/operators/C0002/pbx-groups/Pbx1"
  }],
  "data": [{
    "name": "name",
    "value": "sipServerName"
  }, {
    "name": "externalIp",
    "value": "192.168.1.1"
  }, {
    "name": "internalIp",
    "value": "192.168.1.2"
  }, {
    "name": "subscribersLimit",
    "value": 500
  }, {
    "name": "partition",
    "value": "P01"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
and following body:
{
  "detail": "Resource at /api/operators/C0002/pbx-groups/Pbx1 is of incorrect type",
  "title": "Invalid resource type",
  "described_by": "http://api.nfon.net/probs/invalid-resource-type"
}
Admin cannot create Sip Server if pbxGroup is missing
Given I am authenticated as Admin
When I send /api/sip-servers
with application/json; charset=UTF-8 and following body:
{
  "links": [{
    "rel": "pbxGroup",
    "href": "/api/pbx-groups/Pbx1"
  }],
  "data": [{
    "name": "name",
    "value": "sipServerName"
  }, {
    "name": "externalIp",
    "value": "192.168.1.1"
  }, {
    "name": "internalIp",
    "value": "192.168.1.2"
  }, {
    "name": "subscribersLimit",
    "value": 500
  }, {
    "name": "partition",
    "value": "P01"
  }]
}
Then I should receive HTTP/1.1 404 Not Found
and following body:
{
  "detail": "Pbx Group with name Pbx1 has not been found",
  "title": "Pbx Group not found",
  "described_by": "http://api.nfon.net/probs/pbx-group-not-found"
}
Customer cannot create Sip Server
Given I am authenticated as Customer K0002
When I send /api/sip-servers
with application/json; charset=UTF-8 and following body:
{
  "links": [{
    "rel": "pbxGroup",
    "href": "/api/pbx-groups/Pbx1"
  }],
  "data": [{
    "name": "name",
    "value": "sipServerName"
  }, {
    "name": "externalIp",
    "value": "192.168.1.1"
  }, {
    "name": "internalIp",
    "value": "192.168.1.2"
  }, {
    "name": "partition",
    "value": "P01"
  }]
}
Then I should receive HTTP/1.1 403 Forbidden
with following body:
{
  "detail": "Required role is missing",
  "title": "Access forbidden",
  "described_by": "http://api.nfon.net/probs/invalid-authorization"
}
System Integrator cannot create Sip Server
Given I am authenticated as System Integrator S0002
When I send /api/sip-servers
with application/json; charset=UTF-8 and following body:
{
  "links": [{
    "rel": "pbxGroup",
    "href": "/api/pbx-groups/Pbx1"
  }],
  "data": [{
    "name": "name",
    "value": "sipServerName"
  }, {
    "name": "externalIp",
    "value": "192.168.1.1"
  }, {
    "name": "internalIp",
    "value": "192.168.1.2"
  }, {
    "name": "partition",
    "value": "P01"
  }]
}
Then I should receive HTTP/1.1 403 Forbidden
with following body:
{
  "detail": "Required role is missing",
  "title": "Access forbidden",
  "described_by": "http://api.nfon.net/probs/invalid-authorization"
}
Operator cannot create Sip Server
Given I am authenticated as Operator C0002
When I send /api/sip-servers
with application/json; charset=UTF-8 and following body:
{
  "links": [{
    "rel": "pbxGroup",
    "href": "/api/pbx-groups/Pbx1"
  }],
  "data": [{
    "name": "name",
    "value": "sipServerName"
  }, {
    "name": "externalIp",
    "value": "192.168.1.1"
  }, {
    "name": "internalIp",
    "value": "192.168.1.2"
  }, {
    "name": "partition",
    "value": "P01"
  }]
}
Then I should receive HTTP/1.1 403 Forbidden
with following body:
{
  "title": "Access forbidden",
  "detail": "Required role is missing",
  "described_by": "http://api.nfon.net/probs/invalid-authorization"
}