UNPKG

@cloudonix.io/cloudonix-cli

Version:
98 lines (87 loc) 3.51 kB
/** * ██████╗██╗ ██████╗ ██╗ ██╗██████╗ ██████╗ ███╗ ██╗██╗██╗ ██╗ * ██╔════╝██║ ██╔═══██╗██║ ██║██╔══██╗██╔═══██╗████╗ ██║██║╚██╗██╔╝ * ██║ ██║ ██║ ██║██║ ██║██║ ██║██║ ██║██╔██╗ ██║██║ ╚███╔╝ * ██║ ██║ ██║ ██║██║ ██║██║ ██║██║ ██║██║╚██╗██║██║ ██╔██╗ * ╚██████╗███████╗╚██████╔╝╚██████╔╝██████╔╝╚██████╔╝██║ ╚████║██║██╔╝ ██╗ * ╚═════╝╚══════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝╚═╝ ╚═╝ * * Project: cloudonix-cli | lib/DomainsApi.js * Creator: Nir Simionovich <nirs@cloudonix.io> | 2019-08-27 */ const Client = require('../helpers/Client'); const Api = require('./Api'); class TrunksApi extends Api { static async get(trunkName) { try { var queryPath = (typeof trunkName != 'undefined') ? this._modelQueryPath + "/" + trunkName : this._modelQueryPath; var response = await this._modelHttpConnector.httpConnector.get(queryPath); return { status: response.status, message: response.statusText, data: response.data }; } catch (error) { return { status: error.response.status, message: error.response.statusText, data: false }; } } static async create(trunkName, trunkConfig) { try { var queryPath = this._modelQueryPath; var trunkConfigObject = trunkConfig; trunkConfig.name = trunkName; var response = await this._modelHttpConnector.httpConnector.post(queryPath, trunkConfigObject); return { status: response.status, message: response.statusText, data: response.data }; } catch (error) { return { status: error.response.status, message: error.response.statusText, data: false }; } } static async update(trunkName, trunkConfig) { try { var queryPath = this._modelQueryPath + '/' + trunkName; var trunkConfigObject = trunkConfig; var response = await this._modelHttpConnector.httpConnector.put(queryPath, trunkConfigObject); return { status: response.status, message: response.statusText, data: response.data }; } catch (error) { return { status: error.response.status, message: error.response.statusText, data: false }; } } static async revoke(trunkName) { try { var queryPath = this._modelQueryPath + "/" + trunkName; var response = await this._modelHttpConnector.httpConnector.delete(queryPath); return { status: response.status, message: response.statusText, data: response.data }; } catch (error) { return { status: error.response.status, message: error.response.statusText, data: false }; } } } module.exports = TrunksApi;