Class: SFRest::Cron
- Inherits:
-
Object
- Object
- SFRest::Cron
- Defined in:
- lib/sfrest/cron.rb
Overview
Manipulates SF cron jobs.
Instance Method Summary collapse
-
#create_cron_job(name, command, interval, scope, enabled, thread_percentage, stacks) ⇒ Object
Creates a new cron job rubocop: disable Metrics/ParameterLists.
-
#delete_cron_job(nid) ⇒ Object
Deletes a cron job by its node id.
-
#edit_cron_job(nid, name, command, interval, scope, enabled, thread_percentage, stacks) ⇒ Object
Edits a cron job by its node id rubocop: disable Metrics/ParameterLists.
-
#get_cron_job(nid) ⇒ Object
Gets a cron job by its node id.
-
#get_cron_jobs(page = nil, limit = nil) ⇒ Object
Gets a list of cron jobs.
-
#initialize(conn) ⇒ Cron
constructor
A new instance of Cron.
Constructor Details
#initialize(conn) ⇒ Cron
Returns a new instance of Cron.
7 8 9 |
# File 'lib/sfrest/cron.rb', line 7 def initialize(conn) @conn = conn end |
Instance Method Details
#create_cron_job(name, command, interval, scope, enabled, thread_percentage, stacks) ⇒ Object
Creates a new cron job rubocop: disable Metrics/ParameterLists
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/sfrest/cron.rb', line 37 def create_cron_job(name, command, interval, scope, enabled, thread_percentage, stacks) # rubocop: enable Metrics/ParameterLists payload = { 'name' => name, 'command' => command, 'interval' => interval, 'sites_affected' => scope, 'enabled' => enabled, 'thread_percentage' => thread_percentage, 'stacks' => stacks }.to_json @conn.post('/api/v1/cronjobs', payload) end |
#delete_cron_job(nid) ⇒ Object
Deletes a cron job by its node id
77 78 79 |
# File 'lib/sfrest/cron.rb', line 77 def delete_cron_job(nid) @conn.delete("/api/v1/cronjobs/#{nid}") end |
#edit_cron_job(nid, name, command, interval, scope, enabled, thread_percentage, stacks) ⇒ Object
Edits a cron job by its node id rubocop: disable Metrics/ParameterLists
61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/sfrest/cron.rb', line 61 def edit_cron_job(nid, name, command, interval, scope, enabled, thread_percentage, stacks) # rubocop: enable Metrics/ParameterLists payload = { 'name' => name, 'command' => command, 'interval' => interval, 'sites_affected' => scope, 'enabled' => enabled, 'thread_percentage' => thread_percentage, 'stacks' => stacks }.to_json @conn.put("/api/v1/cronjobs/#{nid}", payload) end |
#get_cron_job(nid) ⇒ Object
Gets a cron job by its node id
24 25 26 |
# File 'lib/sfrest/cron.rb', line 24 def get_cron_job(nid) @conn.get("/api/v1/cronjobs/#{nid}") end |
#get_cron_jobs(page = nil, limit = nil) ⇒ Object
Gets a list of cron jobs
14 15 16 17 18 19 20 |
# File 'lib/sfrest/cron.rb', line 14 def get_cron_jobs(page = nil, limit = nil) args = {} args['page'] = page unless page.nil? args['limit'] = limit unless limit.nil? url = "/api/v1/cronjobs?#{args.map { |k, v| "#{k}=#{v}" }.join('&')}" @conn.get(url) end |