@apillon/sdk
Version:
▶◀ Apillon SDK for NodeJS ▶◀
51 lines • 1.85 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Rpc = void 0;
const apillon_1 = require("../../lib/apillon");
const apillon_api_1 = require("../../lib/apillon-api");
const common_1 = require("../../lib/common");
const rpc_api_key_1 = require("./rpc-api-key");
class Rpc extends apillon_1.ApillonModule {
constructor() {
super(...arguments);
/**
* API URL for RPC module.
*/
this.API_PREFIX = '/rpc';
}
/**
* List all API keys for RPC.
* @param {IApillonPagination} params - The query parameters for filtering API keys.
* @returns The list of API keys.
*/
async listApiKeys(params) {
const url = (0, common_1.constructUrlWithQueryParams)(`${this.API_PREFIX}/api-key`, params);
const data = await apillon_api_1.ApillonApi.get(url);
return Object.assign(Object.assign({}, data), { items: data.items.map((apiKey) => new rpc_api_key_1.RpcApiKey(apiKey.id, apiKey)) });
}
/**
* Create a new API key for RPC module.
* @param {ApillonApiCreateRpcApiKeyDto} data - The data for creating an API key.
* @returns The created API key.
*/
async createApiKey(data) {
const apiKey = await apillon_api_1.ApillonApi.post(`${this.API_PREFIX}/api-key`, data);
return new rpc_api_key_1.RpcApiKey(apiKey.uuid, apiKey);
}
/**
* Get all available endpoints for the RPC service.
* @returns The list of endpoints.
*/
async listEndpoints() {
return await apillon_api_1.ApillonApi.get(`${this.API_PREFIX}/endpoints`);
}
/**
* @param id Unique API key identifier.
* @returns An empty instance of RpcApiKey.
*/
apiKey(id) {
return new rpc_api_key_1.RpcApiKey(id, null);
}
}
exports.Rpc = Rpc;
//# sourceMappingURL=rpc.js.map