add sip_gateways

This commit is contained in:
Dave Horton
2019-12-11 20:47:58 -05:00
parent e186dc2eda
commit 0b54b17c73
8 changed files with 428 additions and 21 deletions

43
lib/models/sip-gateway.js Normal file
View File

@@ -0,0 +1,43 @@
const Model = require('./model');
class SipGateway extends Model {
constructor() {
super();
}
}
SipGateway.table = 'sip_gateways';
SipGateway.fields = [
{
name: 'sip_gateway_sid',
type: 'string',
primaryKey: true
},
{
name: 'voip_carrier_sid',
type: 'string'
},
{
name: 'ipv4',
type: 'string',
required: true
},
{
name: 'port',
type: 'number'
},
{
name: 'inbound',
type: 'number'
},
{
name: 'outbound',
type: 'number'
},
{
name: 'is_active',
type: 'number'
}
];
module.exports = SipGateway;

View File

@@ -10,6 +10,7 @@ function isAdminScope(req, res, next) {
api.use('/ServiceProviders', isAdminScope, require('./service-providers'));
api.use('/VoipCarriers', isAdminScope, require('./voip-carriers'));
api.use('/SipGateways', isAdminScope, require('./sip-gateways'));
api.use('/PhoneNumbers', isAdminScope, require('./phone-numbers'));
api.use('/ApiKeys', require('./api-keys'));
api.use('/Accounts', require('./accounts'));

View File

@@ -0,0 +1,9 @@
const router = require('express').Router();
const SipGateway = require('../../models/sip-gateway');
const decorate = require('./decorate');
const preconditions = {};
decorate(router, SipGateway, ['*'], preconditions);
module.exports = router;

View File

@@ -210,7 +210,144 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/GeneralError'
/SipGateways:
post:
summary: create sip gateway
operationId: createSipGateway
requestBody:
content:
application/json:
schema:
type: object
properties:
voip_carrier_sid:
type: string
description: voip carrier that provides this gateway
format: uuid
ipv4:
type: string
port:
type: number
is_active:
type: boolean
inbound:
type: boolean
outbound:
type: boolean
required:
- voip_carrier_sid
- ipv4
responses:
201:
description: sip gateway successfully created
content:
application/json:
schema:
$ref: '#/components/schemas/SuccessfulAdd'
400:
description: bad request
content:
application/json:
schema:
$ref: '#/components/schemas/GeneralError'
422:
description: unprocessable entity
content:
application/json:
schema:
$ref: '#/components/schemas/GeneralError'
500:
description: system error
content:
application/json:
schema:
$ref: '#/components/schemas/GeneralError'
get:
summary: list sip gateways
operationId: listSipGateways
responses:
200:
description: list of sip gateways
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/SipGateway'
500:
description: system error
content:
application/json:
schema:
$ref: '#/components/schemas/GeneralError'
/SipGateways/{SipGatewaySid}:
parameters:
- name: SipGatewaySid
in: path
required: true
style: simple
explode: false
schema:
type: string
delete:
summary: delete a sip gateway
operationId: deleteSipGateway
responses:
204:
description: sip gateway successfully deleted
404:
description: sip gateway not found
500:
description: system error
content:
application/json:
schema:
$ref: '#/components/schemas/GeneralError'
get:
summary: retrieve sip gateway
operationId: getSipGateway
responses:
200:
description: sip gateway found
content:
application/json:
schema:
$ref: '#/components/schemas/VoipCarrier'
404:
description: sip gateway not found
500:
description: system error
content:
application/json:
schema:
$ref: '#/components/schemas/GeneralError'
put:
summary: update sip gateway
operationId: updateSipGateway
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/SipGateway'
responses:
204:
description: sip gateway updated
400:
description: bad request
content:
application/json:
schema:
$ref: '#/components/schemas/GeneralError'
404:
description: sip gateway not found
500:
description: system error
content:
application/json:
schema:
$ref: '#/components/schemas/GeneralError'
/PhoneNumbers:
post:
summary: provision a phone number into inventory from a Voip Carrier
@@ -1051,6 +1188,30 @@ components:
required:
- voip_carrier_sid
- name
SipGateway:
type: object
properties:
sip_gateway_sid:
type: string
format: uuid
ipv4:
type: string
port:
type: number
voip_carrier_sid:
type: string
format: uuid
is_active:
type: boolean
inbound:
type: boolean
outbound:
type: boolean
required:
- sip_gateway_sid
- voip_carrier_sid
- ipv4
- port
Account:
type: object
properties: