diff --git a/db/jambones-sql.sql b/db/jambones-sql.sql index 5b66797..4c3bd38 100644 --- a/db/jambones-sql.sql +++ b/db/jambones-sql.sql @@ -1,6 +1,5 @@ /* SQLEditor (MySQL (2))*/ -SET FOREIGN_KEY_CHECKS = 0; DROP TABLE IF EXISTS `call_routes`; @@ -10,6 +9,8 @@ DROP TABLE IF EXISTS `lcr_routes`; DROP TABLE IF EXISTS `api_keys`; +DROP TABLE IF EXISTS `users`; + DROP TABLE IF EXISTS `phone_numbers`; DROP TABLE IF EXISTS `sip_gateways`; @@ -24,8 +25,6 @@ DROP TABLE IF EXISTS `service_providers`; DROP TABLE IF EXISTS `webhooks`; -SET FOREIGN_KEY_CHECKS = 1; - CREATE TABLE IF NOT EXISTS `call_routes` ( `call_route_sid` CHAR(36) NOT NULL UNIQUE , @@ -51,9 +50,19 @@ CREATE TABLE IF NOT EXISTS `api_keys` `token` CHAR(36) NOT NULL UNIQUE , `account_sid` CHAR(36), `service_provider_sid` CHAR(36), +`expires_at` TIMESTAMP, PRIMARY KEY (`api_key_sid`) ) ENGINE=InnoDB COMMENT='An authorization token that is used to access the REST api'; +CREATE TABLE IF NOT EXISTS `users` +( +`user_sid` CHAR(36) NOT NULL UNIQUE , +`name` CHAR(36) NOT NULL UNIQUE , +`hashed_password` VARCHAR(1024) NOT NULL, +`salt` CHAR(16) NOT NULL, +PRIMARY KEY (`user_sid`) +); + CREATE TABLE IF NOT EXISTS `voip_carriers` ( `voip_carrier_sid` CHAR(36) NOT NULL UNIQUE , @@ -97,7 +106,7 @@ PRIMARY KEY (`lcr_carrier_set_entry_sid`) CREATE TABLE IF NOT EXISTS `sip_gateways` ( `sip_gateway_sid` CHAR(36), -`ipv4` VARCHAR(32) NOT NULL COMMENT 'ip address or DNS name of the gateway. For gateways providing inbound calling service, ip address is required.', +`ipv4` VARCHAR(128) NOT NULL COMMENT 'ip address or DNS name of the gateway. For gateways providing inbound calling service, ip address is required.', `port` INTEGER NOT NULL DEFAULT 5060 COMMENT 'sip signaling port', `inbound` BOOLEAN NOT NULL COMMENT 'if true, whitelist this IP to allow inbound calls from the gateway', `outbound` BOOLEAN NOT NULL COMMENT 'if true, include in least-cost routing when placing calls to the PSTN', @@ -114,7 +123,8 @@ CREATE TABLE IF NOT EXISTS `applications` `call_hook_sid` CHAR(36) COMMENT 'webhook to call for inbound calls to phone numbers owned by this account', `call_status_hook_sid` CHAR(36) COMMENT 'webhook to call for call status events', `speech_synthesis_vendor` VARCHAR(64) NOT NULL DEFAULT 'google', -`speech_synthesis_voice` VARCHAR(64) NOT NULL DEFAULT 'en-US-Wavenet-C', +`speech_synthesis_language` VARCHAR(12) NOT NULL DEFAULT 'en-US', +`speech_synthesis_voice` VARCHAR(64), `speech_recognizer_vendor` VARCHAR(64) NOT NULL DEFAULT 'google', `speech_recognizer_language` VARCHAR(64) NOT NULL DEFAULT 'en-US', PRIMARY KEY (`application_sid`) @@ -154,6 +164,8 @@ ALTER TABLE `api_keys` ADD FOREIGN KEY account_sid_idxfk_1 (`account_sid`) REFER CREATE INDEX `api_keys_service_provider_sid_idx` ON `api_keys` (`service_provider_sid`); ALTER TABLE `api_keys` ADD FOREIGN KEY service_provider_sid_idxfk (`service_provider_sid`) REFERENCES `service_providers` (`service_provider_sid`); +CREATE INDEX `users_user_sid_idx` ON `users` (`user_sid`); +CREATE INDEX `users_name_idx` ON `users` (`name`); CREATE INDEX `voip_carriers_voip_carrier_sid_idx` ON `voip_carriers` (`voip_carrier_sid`); CREATE INDEX `voip_carriers_name_idx` ON `voip_carriers` (`name`); ALTER TABLE `voip_carriers` ADD FOREIGN KEY account_sid_idxfk_2 (`account_sid`) REFERENCES `accounts` (`account_sid`); diff --git a/db/jambones.sqs b/db/jambones.sqs index 25033eb..887548c 100644 --- a/db/jambones.sqs +++ b/db/jambones.sqs @@ -1,5 +1,48 @@ + + + + + 1560.00 + 65.00 + + + 250.00 + 110.00 + + 11 + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -83,7 +126,7 @@ 252.00 - 100.00 + 120.00 1 @@ -132,6 +175,11 @@ + + + + + @@ -529,7 +577,7 @@ - + @@ -611,7 +659,7 @@ 345.00 - 220.00 + 240.00 0 @@ -683,11 +731,17 @@ + + + + + + + - - + @@ -850,17 +904,17 @@ - + - - - + + + - + diff --git a/lib/swagger/swagger.yaml b/lib/swagger/swagger.yaml index cbb9660..83d47c4 100644 --- a/lib/swagger/swagger.yaml +++ b/lib/swagger/swagger.yaml @@ -28,6 +28,9 @@ paths: account_sid: type: string description: account scope for the generated api key + expiry_secs: + type: number + description: duration of key validity, in seconds responses: 201: description: api key successfully created @@ -64,6 +67,80 @@ paths: 404: description: api key or account not found + /login: + post: + summary: login a user and receive an api token + operationId: loginUser + requestBody: + content: + application/json: + schema: + type: object + properties: + username: + type: string + description: login username + password: + type: string + description: login password + required: + - username + - password + responses: + 200: + description: login succeeded + content: + application/json: + schema: '#/components/schemas/SuccessfulLogin' + 403: + description: login failed + content: + application/json: + schema: + $ref: '#/components/schemas/GeneralError' + 500: + description: system error + content: + application/json: + schema: + $ref: '#/components/schemas/GeneralError' + /User/{UserSid}: + put: + summary: update a user password + operationId: updateUser + requestBody: + content: + application/json: + schema: + type: object + properties: + old_password: + type: string + description: existing password, which is to be replaced + new_password: + type: string + description: new password + required: + - old_password + - new_password + responses: + 200: + description: password successfully changed + content: + application/json: + schema: '#/components/schemas/SuccessfulLogin' + 403: + description: password change failed + content: + application/json: + schema: + $ref: '#/components/schemas/GeneralError' + 500: + description: system error + content: + application/json: + schema: + $ref: '#/components/schemas/GeneralError' /VoipCarriers: post: summary: create voip carrier @@ -1240,6 +1317,17 @@ components: scheme: bearer bearerFormat: token schemas: + SuccessfulLogin: + type: object + properties: + user_sid: + type: string + api_token: + type: string + change_password: + type: boolean + required: + - user_sid SuccessfulApiKeyAdd: type: object required: