Api >

Service Portal REST API

Can create a Router for Customer with POST
Given I am authenticated as System Integrator S0002
and next router id is 700
When I send /api/customers/K0002/routers as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "hostname",
    "value": "router.hostname.de"
  }, {
    "name": "comment",
    "value": "router comment"
  }]
}
Then I should receive HTTP/1.1 201 Created with http://localhost:9998/api/customers/K0002/routers/700
and body
{
  "href": "/api/customers/K0002/routers/700"
}
and authenticated call to /api/customers/K0002/routers/700 should return:
{
  "href": "/api/customers/K0002/routers/700",
  "links": [],
  "data": [{
    "name": "hostname",
    "value": "router.hostname.de"
  }, {
    "name": "type",
    "value": null
  }, {
    "name": "comment",
    "value": "router comment"
  }, {
    "name": "monitor",
    "value": false
  }, {
    "name": "manageableInPortal",
    "value": true
  }]
}
Comment is required while creating router
Given I am authenticated as System Integrator S0002
When I send /api/customers/K0002/routers as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "hostname",
    "value": "router.hostname.de"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
And Content-Type header should be application/api-problem+json
with following body:
{
  "title": "Validation error",
  "detail": "Could not create or update resource due to constraint violations",
  "errors": [{
    "message": "Value must be provided",
    "path": "comment"
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
Hostname is required while creating router
Given I am authenticated as System Integrator S0002
When I send /api/customers/K0002/routers as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "comment",
    "value": "new router"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
And Content-Type header should be application/api-problem+json
with following body:
{
  "title": "Validation error",
  "detail": "Could not create or update resource due to constraint violations",
  "errors": [{
    "message": "Value must be provided",
    "path": "hostname"
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
Hostname must be unique for a customer
Given I am authenticated as System Integrator S0002
and there is a Router with hostname router.hostname.de
And then when I again send /api/customers/K0002/routers as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "hostname",
    "value": "router.hostname.de"
  }, {
    "name": "comment",
    "value": "router comment"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
And Content-Type header should be application/api-problem+json
with following body:
{
  "title": "Hostname must be unique",
  "detail": "There is already a router with name 'router.hostname.de' defined!",
  "described_by": "http://api.nfon.net/probs/router-hostname-unique"
}
Customer cannot create router
Given I am authenticated as customer K0002
When I send /api/customers/K0002/routers as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "hostname",
    "value": "router.hostname.de"
  }, {
    "name": "comment",
    "value": "router comment"
  }]
}
Then I should receive HTTP/1.1 403 Forbidden
And Content-Type header should be application/api-problem+json
with following body:
{
  "title": "Access forbidden",
  "detail": "Required role is missing",
  "described_by": "http://api.nfon.net/probs/invalid-authorization"
}
Missing Customer
Given I am authenticated as Admin
When try to create router for not existing customer with request /api/customers/K404/routers as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "hostname",
    "value": "router.hostname.de"
  }, {
    "name": "comment",
    "value": "router comment"
  }]
}
Then I should receive HTTP/1.1 404 Not Found
And Content-Type header should be application/api-problem+json
with following body:
{
  "title": "Customer not found",
  "detail": "Customer with identifier K404 has not been found",
  "described_by": "http://api.nfon.net/probs/customer-not-found"
}
System Integrator cannot create Router for Customer that does not belong to him
Given I am authenticated as System Integrator S0002
When I send /api/customers/K0003/routers as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "hostname",
    "value": "router.hostname.de"
  }, {
    "name": "comment",
    "value": "router comment"
  }]
}
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 create Router for Customer that does not belong to him
Given I am authenticated as Operator C0002
When I send /api/customers/K0003/routers as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "hostname",
    "value": "router.hostname.de"
  }, {
    "name": "comment",
    "value": "router comment"
  }]
}
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"
}