UNPKG

@gabrielvgx/tecfoodcli

Version:

Projeto para automatizar criação de ambientes TecFood

75 lines (64 loc) 1.52 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _axios = _interopRequireDefault(require("axios")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const gitlab = { host: "", token: "", email: "", endPoints: { API: "/api/v4", SSH: "/user/keys" }, getHeader() { return { "PRIVATE-TOKEN": this.token }; }, getDefaultOptions() { return { headers: this.getHeader() }; }, getUrlApi() { return this.host + this.endPoints.API; }, async listSSH() { const URL = this.getUrlApi() + this.endPoints.SSH; const options = this.getDefaultOptions(); const { data } = await _axios.default.get(URL, options); return data; }, async createSSH(title, key, expires_at = null) { const URL = this.getUrlApi() + this.endPoints.SSH; const options = this.getDefaultOptions(); options.data = { title, key, expires_at }; options.method = 'POST'; options.url = URL; const { data } = await (0, _axios.default)(options).catch(error => { console.log(error); }); return data; }, async deleteSSH(keyID) { const URL = this.getUrlApi() + this.endPoints.SSH + '/' + keyID; const options = this.getDefaultOptions(); const { data } = await _axios.default.delete(URL, options); return data; } }; var _default = gitlab; exports.default = _default;