Api >

Service Portal REST API

POST creates Lync Sites
Given I am authenticated as Admin
and there is a Lync Gateway with id 200 and name Lync Gateway
and next available identifier for Lync Site is 500
When I send /api/customers/K0002/lync/sites as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "gateway",
    "href": "/api/customers/K0002/lync/gateways/200"
  }],
  "data": [{
    "name": "domain",
    "value": "nfon.net"
  }, {
    "name": "description",
    "value": "Lync Site"
  }]
}
Then I should receive HTTP/1.1 201 Created
and authenticated call to /api/customers/K0002/lync/sites/500 should return:
{
  "href": "/api/customers/K0002/lync/sites/500",
  "links": [{
    "rel": "gateway",
    "href": "/api/customers/K0002/lync/gateways/200"
  }],
  "data": [{
    "name": "serverName",
    "value": "Lync Gateway"
  }, {
    "name": "domain",
    "value": "nfon.net"
  }, {
    "name": "description",
    "value": "Lync Site"
  }]
}
Lync Site domain must be unique
Given I am authenticated as Admin
and there is a Lync Gateway with id 200 and name Lync Gateway
and there is a LyncSite with id 500 and name Lync Site
and it has domain set to nfon.net
When I send /api/customers/K0002/lync/sites as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "gateway",
    "href": "/api/customers/K0002/lync/gateways/200"
  }],
  "data": [{
    "name": "description",
    "value": "Lync Site"
  }, {
    "name": "domain",
    "value": "nfon.net"
  }]
}
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": "LyncSite with given domain already exists",
    "path": "domain",
    "value": "nfon.net"
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
Cannot use different customer Lync Gateway to create Lync Sites
Given I am authenticated as Admin
and there is a Lync Gateway with id 200 and name Lync Gateway
When I send /api/customers/K0003/lync/sites as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "gateway",
    "href": "/api/customers/K0002/lync/gateways/200"
  }],
  "data": [{
    "name": "domain",
    "value": "nfon.net"
  }, {
    "name": "description",
    "value": "Lync Site"
  }]
}
Then I should receive HTTP/1.1 400 Bad Request
And Content-Type header should be application/api-problem+json
with following body:
{
  "detail": "Could not create or update resource due to constraint violations",
  "title": "Validation error",
  "errors": [{
    "message": "[K0003] cannot use a Lync Gateway of other customer[K0002]",
    "path": "/api/customers/K0002/lync/sites/0",
    "value": null
  }],
  "described_by": "http://api.nfon.net/probs/validation-error"
}
Fail meaningfully when trying to create Lync Site for not existing Customer
Given I am authenticated as Admin
When I send /api/customers/K0404/lync/sites as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "gateway",
    "href": "/api/customers/K0002/lync/gateways/200"
  }],
  "data": [{
    "name": "domain",
    "value": "nfon.net"
  }, {
    "name": "description",
    "value": "Lync Site"
  }]
}
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 K0404 has not been found",
  "described_by": "http://api.nfon.net/probs/customer-not-found"
}
Customer cannot create Lync Sites
Given I am authenticated as customer K0002
When I send /api/customers/K0002/lync/sites as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "gateway",
    "href": "/api/customers/K0002/lync/gateways/200"
  }],
  "data": [{
    "name": "domain",
    "value": "nfon.net"
  }, {
    "name": "description",
    "value": "Lync Site"
  }]
}
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"
}
System Integrator cannot create Lync Site
Given I am authenticated as System Integrator S0002
When I send /api/customers/K0002/lync/sites as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "gateway",
    "href": "/api/customers/K0002/lync/gateways/200"
  }],
  "data": [{
    "name": "domain",
    "value": "nfon.net"
  }, {
    "name": "description",
    "value": "Lync Site"
  }]
}
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"
}
Operator cannot create Lync Site
Given I am authenticated as Operator C0002
When I send /api/customers/K0002/lync/sites as application/json; charset=UTF-8 with following body:
{
  "links": [{
    "rel": "gateway",
    "href": "/api/customers/K0002/lync/gateways/200"
  }],
  "data": [{
    "name": "domain",
    "value": "nfon.net"
  }, {
    "name": "description",
    "value": "Lync Site"
  }]
}
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"
}