Skip to content

Programmatic Usage

Serban Petrescu edited this page Mar 13, 2018 · 2 revisions

The library can be easily used programmatically. All the commands exposed in the CLI are backed up by a method in a specialised public API class.

The default export of the module is a factory function. The function may optionally receive a configuration object (same structure as the .sapim file). If this parameter is omitted, then the default configuration is loaded using the mechanism described in the Configuration page.

All methods return promise-based results.

Example usage:

    var sapim = require("sapim").default();
    sapim.deployManifest("/path/to/my/manifest.yaml").then(function() {
        console.log("Success!");
    });

The library has an own logging abstraction (which is exported by the library as the logger object). Consumers have the option to change the logging level or even to replace the default logging mechanism.

    var logger = require('sapim').logger;
    var LOG_LEVEL = require('sapim').LOG_LEVEL;

    logger.setLevel(LOG_LEVEL.ERROR);
Clone this wiki locally