cronitor-client

1.1.0 • Public • Published

nodejs cronitor.io client


An unofficial simple asynchronous node.js client to ease working with cronitor.io API's.

Test


# Set 'ACCESS_TOKEN' in environment variable and then run tests
	
$ npm install
$ npm install gulp -g
$ npm test

How-to

  • Create new CronitorClient instance
var cc = new CronitorClient({
                access_token: <Acess key here> });
  • Start using it

Create new monitor

Args: new( monitor-object, callback)

# Create new monitor
 
var newMonitor = {
        "name": data[1]+"_"+ uid(10),
        "notifications": {
            "phones": [], 
            "webhooks": [], 
            "emails": [
                "sonukr666@xyz.com"
            ]
        }, 
        "rules": [
            {
                "rule_type": "not_run_in", 
                "duration": 1, 
                "time_unit": "minutes"
            },
            {
                "rule_type": "ran_longer_than", 
                "duration": 1, 
                "time_unit": "minutes"
            }
        ],
        "note": data[2]
    };
 
cc.new( newMonitor, function(err, body){
    if( err){
        console.log( err);
        throw new Error( err );
    }else{
        console.log( "Cron created", body.code );
    }
});

Get all monitors

Args: all(options, callback)

# Get all monitor
cc.all( function(err, body){
    if(!err){
            console.log( body);
            }
        });
OR
 
cc.all( {page:2}, function(err, body){
    if(!err){
            console.log( body);
            }
        });

Get single monitor

Args: get( monitor code, callback)...

cc.get('myMonitor_code',  function(err, monitor){
            console.log( monitor);
        });

Update monitor

Args: update( monitor-code, monitor-obj, callback)...

var updateMonitorObj = {...}
cc.update( 'myMonitor_code', updateMonitorObj, function(err, body){
    if( err){
        console.log( err);
        throw new Error( err );
    }else{
        console.log( "monitor updated", body );
    }
});

Delete monitor

Args: delete( monitor-code, callback)...

cc.delete( 'myMonitor_code', function(err, body){
    if( err){
        console.log( err);
        throw new Error( err );
    }else{
        console.log( "monitor deleted" );
    }
});

Unpause monitor

Args: unpause( monitor-code, callback)...

cc.unpause( 'myMonitor_code', function(err, body){
    if( err){
        console.log( err);
        throw new Error( err );
    }else{
        console.log( "monitor unpaused" );
    }
});

Problem using cronitor-Client?

===============================

File an issue on https://github.com/sahilsk/node-cronitor-client

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i cronitor-client

Weekly Downloads

1

Version

1.1.0

License

MIT

Last publish

Collaborators

  • sahilsk