Api >

Service Portal REST API

Can change a Managed Router for Customer with PUT
Given I am authenticated as System Integrator S0002
and next router id is 700
and there is a router with hostname router.hostname.de
When I send /api/customers/K0002/routers/700 as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "hostname",
    "value": "changed.router.hostname.de"
  }, {
    "name": "comment",
    "value": "changed router comment"
  }, {
    "name": "monitor",
    "value": true
  }, {
    "name": "type",
    "value": "changed type"
  }]
}
Then I should receive HTTP/1.1 204 No Content
and authenticated call to /api/customers/K0002/routers/700 should return:
{
  "href": "/api/customers/K0002/routers/700",
  "data": [{
    "name": "hostname",
    "value": "changed.router.hostname.de"
  }, {
    "name": "type",
    "value": "changed type"
  }, {
    "name": "comment",
    "value": "changed router comment"
  }, {
    "name": "monitor",
    "value": true
  }, {
    "name": "manageableInPortal",
    "value": true
  }]
}
Comment cannot be empty while changing router
Given I am authenticated as System Integrator S0002
and next router id is 700
and there is a router with hostname router.hostname.de
When I send /api/customers/K0002/routers/700 as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "comment",
    "value": ""
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
And Content-Type header should be application/api-problem+json
with following body:
{
  "title": "Comment is required",
  "detail": "Comment cannot be blank",
  "described_by": "http://api.nfon.net/probs/router-comment-required"
}
Hostname cannot be empty while changing router
Given I am authenticated as System Integrator S0002
and next router id is 700
and there is a router with hostname router.hostname.de
When I send /api/customers/K0002/routers/700 as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "hostname",
    "value": ""
  }]
}
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 is required",
  "detail": "Hostname cannot be blank",
  "described_by": "http://api.nfon.net/probs/router-hostname-required"
}
Hostname must be unique for a customer
Given I am authenticated as System Integrator S0002
and next router id is 700
and there is a router with hostname router.hostname.de
and there is a another router with hostname another.hostname.de
When I send /api/customers/K0002/routers/700 as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "hostname",
    "value": "another.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": "Hostname must be unique",
  "detail": "There is already a router with name 'another.hostname.de' defined!",
  "described_by": "http://api.nfon.net/probs/router-hostname-unique"
}
Customer cannot change router
Given I am authenticated as customer K0002
and next router id is 700
and there is a router with hostname router.hostname.de
When I send /api/customers/K0002/routers/700 as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "comment",
    "value": "new 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"
}
Cannot change managed router
Given I am authenticated as System Integrator S0002
and next router id is 700
and there is a not managable router with hostname router.hostname.de
When I send /api/customers/K0002/routers/700 as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "hostname",
    "value": "router.hostname.de"
  }, {
    "name": "comment",
    "value": "new 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": "Managed routers cannot be changed",
  "detail": "Router with ID 700 is managed, therefore cannot be changed via API call",
  "described_by": "http://api.nfon.net/probs/cannot-delete-non-managed-router"
}
Missing Customer
Given I am authenticated as Admin
When try to change router for not existing customer with request /api/customers/K404/routers/700 as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "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"
}
Wrong Customer
Given I am authenticated as System Integrator S0003
and next router id is 700
and there is a Router with hostname router.hostname.de
When try to change router for wrong customer with request /api/customers/K0003/routers/700 as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "name": "comment",
    "value": "new 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": "Wrong customer",
  "detail": "Router with ID 700 belongs to another customer",
  "described_by": "http://api.nfon.net/probs/wrong-customer"
}
Cannot change not existing router
Given I am authenticated as System Integrator S0002
When try to change router for not existing customer with request /api/customers/K0002/routers/404 as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "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": "Router not found",
  "detail": "Router with ID 404 has not been found",
  "described_by": "http://api.nfon.net/probs/router-not-found"
}
System Integrator cannot change Router of Customer that does not belong to him
Given I am authenticated as System Integrator S0002
When try to change router for not existing customer with request /api/customers/K0003/routers/700 as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "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 change Router of Customer that does not belong to him
Given I am authenticated as Operator C0002
When try to change router for not existing customer with request /api/customers/K0003/routers/700 as application/json; charset=UTF-8 with following body:
{
  "data": [{
    "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"
}