Skip to content

Commit

Permalink
Version 0.9.23
Browse files Browse the repository at this point in the history
- Added new `get_master_state` API and docs.
- Added docs for  `update_master_state` API.
  • Loading branch information
jhuckaby committed Jun 2, 2023
1 parent 83681fb commit 20a7502
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
47 changes: 47 additions & 0 deletions docs/APIReference.md
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,53 @@ Example response:

See the [Standard Response Format](APIReference.md#standard-response-format) for details.

### get_master_state

```
/api/app/get_master_state/v1
```

This fetches the current application "state", which contains information like the status of the scheduler (enabled or disabled). The API accepts no parameters. Example response:

```js
{
"code": 0,
"state": { "enabled": 1 }
}
```

In addition to the [Standard Response Format](APIReference.md#standard-response-format), the response object will contain a `state` object. This will contain an `enabled` property, which indicates the current state of the scheduler (enabled or disabled). It may also contain other properties, but they are for internal use and can be ignored.

### update_master_state

```
/api/app/update_master_state/v1
```

This updates the master application state, i.e. toggling the scheduler on/off. API Keys require the `state_update` privilege to use this API. Only HTTP POST (JSON data) is acceptable. The parameters are as follows:

| Parameter Name | Description |
|----------------|-------------|
| `enabled` | **(Required)** The desired new state of the scheduler (`1` for enabled or `0` for disabled). |

Example request:

```js
{
"enabled": 1
}
```

Example response:

```js
{
"code": 0
}
```

See the [Standard Response Format](APIReference.md#standard-response-format) for details.

## Event Data Format

Here are descriptions of all the properties in the event object, which is common in many API calls:
Expand Down
14 changes: 14 additions & 0 deletions lib/api/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,20 @@ module.exports = Class.create({
} );
},

api_get_master_state: function(args, callback) {
// get master state (i.e. scheduler enabled)
var self = this;
var params = args.params;
if (!this.requireMaster(args, callback)) return;

this.loadSession(args, function(err, session, user) {
if (err) return self.doError('session', err.message, callback);
if (!self.requireValidUser(session, user, callback)) return;

callback({ code: 0, state: self.state });
} );
},

api_update_master_state: function(args, callback) {
// update master state (i.e. scheduler enabled)
var self = this;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Cronicle",
"version": "0.9.22",
"version": "0.9.23",
"description": "A simple, distributed task scheduler and runner with a web based UI.",
"author": "Joseph Huckaby <jhuckaby@gmail.com>",
"homepage": "https://github.com/jhuckaby/Cronicle",
Expand Down

0 comments on commit 20a7502

Please sign in to comment.