0.01
No commit activity in last 3 years
No release in over 3 years
A simple REST client for the Chronos API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0
~> 3.0
>= 2.7.0

Runtime

~> 0.11.0
>= 0
~> 2.0.0
 Project Readme

chronos-api

Gem Version travis-ci

This gem provides a CLI and a simple REST API client for Chronos.

Installation

Add this line to your application's Gemfile:

gem 'chronos-api', :require => 'chronos'

And then run:

$ bundle install

Usage

If you're running Chronos locally on port 4400, there is no setup to do in Ruby. If you're not or change the path or port, you'll have to point the gem to your socket or local/remote port. For example:

Chronos.url = 'http://example.com:8080'

It's possible to use ENV variables to configure the endpoint as well:

$ CHRONOS_URL=http://remote.chronos.example.com:8080 irb
irb(main):001:0> require 'chronos'
=> true
irb(main):002:0> Chronos.url
=> "http://remote.chronos.example.com:8080"

Authentification

You have two options to set authentification if your Chronos API requires it:

Chronos.options = {:username => 'your-user-name', :password => 'your-secret-password'}

or

$ export CHRONOS_USER=your-user-name
$ export CHRONOS_PASSWORD=your-secret-password
$ irb
irb(main):001:0> require 'chronos'
=> true
irb(main):002:0> Chronos.options
=> {:username => "your-user-name", :password => "your-secret-password"}

or

$ chronos -c http://USERNAME:PASSWORD@HOST:PORT

List

To list the current scheduled jobs:

require 'chronos'
jobs = Chronos.list

or

$ chronos list

Add a job

To add a new job:

require 'chronos'
Chronos.add({
  name: 'myjob',
  schedule: 'R10/2012-10-01T05:52:00Z/PT2S',
  epsilon: 'PT15M',
  command: 'echo foobar',
  owner: 'chronos@algolia.com',
  async: false
})

or

$ chronos add --job /path/to/job/details.json

Delete a job

To delete a job:

require 'chronos'
Chronos.delete('job_name')

or

$ chronos delete --name job_name

Delete all jobs

To delete all jobs:

require 'chronos'
Chronos.delete_all

or

$ chronos delete_all

Manually start a job

To manually start a job:

require 'chronos'
Chronos.start('job_name')

or

$ chronos start --name job_name

Contributing

Please fork and send pull request. Make sure to have test cases for your changes.

Credits

This gem has been highly inspired by marathon-api.

License

This program is licensed under the MIT license. See LICENSE for details.