UNPKG

@translated/lara

Version:

Official Lara SDK for JavaScript and Node.js

64 lines (63 loc) • 2.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Styleguides = void 0; const errors_1 = require("./errors"); class Styleguides { constructor(client) { this.client = client; } /** @deprecated Use listPaginated() instead. */ async list() { return await this.client.get("/v2/styleguides"); } /** * List resources with optional name filtering and pagination. * Without options, returns the complete list of resources without pagination. * Providing search, page, or size enables pagination; omitted page and size default to 1 and 20. */ async listPaginated(options) { return await this.client.getCollection("/v2/styleguides", options); } async get(id) { try { return await this.client.get(`/v2/styleguides/${id}`); } catch (e) { if (e instanceof errors_1.LaraApiError && e.statusCode === 404) { return null; } throw e; } } async create(name, content) { return await this.client.post("/v2/styleguides", { name, content }); } async update(id, name, content) { return await this.client.put(`/v2/styleguides/${id}`, { name, content }); } async delete(id) { return await this.client.delete(`/v2/styleguides/${id}`); } async getShares(id) { return await this.client.get(`/v2/styleguides/${id}/shares`); } async addAccountShare(id, name) { return await this.client.post(`/v2/styleguides/${id}/shares`, { name }); } async revokeAccountShare(id) { return await this.client.delete(`/v2/styleguides/${id}/shares`); } async renameAccountShare(id, name) { return await this.client.put(`/v2/styleguides/${id}/shares`, { name }); } async addGroupShare(id, groupId, name) { return await this.client.post(`/v2/styleguides/${id}/shares/groups/${groupId}`, { name }); } async revokeGroupShare(id, groupId) { return await this.client.delete(`/v2/styleguides/${id}/shares/groups/${groupId}`); } async renameGroupShare(id, groupId, name) { return await this.client.put(`/v2/styleguides/${id}/shares/groups/${groupId}`, { name }); } } exports.Styleguides = Styleguides;