@apillon/sdk
Version:
▶◀ Apillon SDK for NodeJS ▶◀
58 lines • 2.37 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CloudFunctions = void 0;
const apillon_1 = require("../../lib/apillon");
const apillon_api_1 = require("../../lib/apillon-api");
const common_1 = require("../../lib/common");
const cloud_function_1 = require("./cloud-function");
const cloud_function_job_1 = require("./cloud-function-job");
class CloudFunctions extends apillon_1.ApillonModule {
constructor() {
super(...arguments);
/**
* API url for cloud functions.
*/
this.API_PREFIX = '/cloud-functions';
}
/**
* Lists all cloud functions.
* @param {IApillonPagination} params Filter for listing cloud functions.
* @returns Array of CloudFunction objects.
*/
async listCloudFunctions(params) {
const url = (0, common_1.constructUrlWithQueryParams)(this.API_PREFIX, params);
const data = await apillon_api_1.ApillonApi.get(url);
return Object.assign(Object.assign({}, data), { items: data.items.map((cf) => {
const cloudFunction = new cloud_function_1.CloudFunction(cf.functionUuid, cf);
delete cloudFunction.jobs;
return cloudFunction;
}) });
}
/**
* Creates a new cloud function based on the provided data.
* @param {ICreateApillonModel} data Data for creating the cloud function.
* @returns {CloudFunction} Newly created cloud function.
*/
async createCloudFunction(data) {
const cloudFunction = await apillon_api_1.ApillonApi.post(this.API_PREFIX, data);
return new cloud_function_1.CloudFunction(cloudFunction.functionUuid, cloudFunction);
}
/**
* Gets a specific cloud function.
* @param {string} uuid Unique identifier of the cloud function.
* @returns {CloudFunction} An empty instance of CloudFunction.
*/
cloudFunction(uuid) {
return new cloud_function_1.CloudFunction(uuid);
}
/**
* Gets a specific cloud function job.
* @param {string} uuid Unique identifier of the cloud function job.
* @returns {CloudFunctionJob} An empty instance of CloudFunctionJob.
*/
cloudFunctionJob(uuid) {
return new cloud_function_job_1.CloudFunctionJob(uuid);
}
}
exports.CloudFunctions = CloudFunctions;
//# sourceMappingURL=cloud-functions.js.map