iron_worker_ng 1.5.1 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8b0e4d4aa270911d8fb351eef0d9f699bed21645
4
- data.tar.gz: d375f5157a3eccac3a39291f8ebcdba23e7bcfd7
3
+ metadata.gz: a654f4e22e048d2a9812b02b4355704b5f6c6670
4
+ data.tar.gz: 4ed6669f27699dcd3f4ca51f91e2a07dd124c454
5
5
  SHA512:
6
- metadata.gz: c312b4699081f8f2f1da4f5ee39dba3c097e5bc1e5c2deb3d7cf3d540610e5c399a29f80d935abdb3cddbe1e70928e43b6c7fb526358e593b2e8301f6a540473
7
- data.tar.gz: 89e486619760f5b0720b966fada3e623a08ed428dc6f1d1d7d43c5469dcbfdcb69c6e6a24b11a3297573f4207a981278453df36faecb3669e7bf6fc6f19a3fd4
6
+ metadata.gz: 02beee3cc652603989da4eba6005c3ec9ee9f9adcf4738289c85fca859bfd51bd8f8592b7ee25575f5ad7dd8ddc0e7e0395446cf24f14ec97da42e25f7e13ec2
7
+ data.tar.gz: 166cbabf5dcb22a8e2116c3970c7a7b3e230c89af887fcca8058e9ceac130d7caaff3231c49ab3aeee5e361ef1b15889ae33f55c33922cabf0a8c350df5d91b2
data/README.md CHANGED
@@ -620,6 +620,18 @@ puts schedule.id
620
620
  - **label**: Optional label for adding custom labels to scheduled tasks.
621
621
  - **cluster**: cluster name ex: "high-mem" or "dedicated". This is a premium feature for customers to have access to more powerful or custom built worker solutions. Dedicated worker clusters exist for users who want to reserve a set number of workers just for their queued tasks. If not set default is set to "default" which is the public IronWorker cluster.
622
622
 
623
+ ### schedules.update(schedule_id, options = {})
624
+
625
+ Update a scheduled task specified by id
626
+
627
+ ```ruby
628
+ client.schedules.update('545b3cb829acd33ea10016e4', {label: 'new_label'})
629
+ ```
630
+
631
+ Or you can update a scheduled task for your worker from the command line using:
632
+
633
+ iron_worker update schedule 545b3cb829acd33ea10016e4 -s '{"label": "new_label"}'
634
+
623
635
  ### schedules.cancel(schedule_id)
624
636
 
625
637
  Cancel the scheduled task specified by `schedule_id`.
data/bin/iron_worker CHANGED
@@ -41,7 +41,7 @@ if $*.size == 1 && ($*[0] == '-v' || $*[0] == '--version')
41
41
  exit 0
42
42
  end
43
43
 
44
- commands = ['upload', 'patch', 'queue', 'retry', 'schedule', 'log', 'run', 'install', 'webhook', 'info', 'stacks']
44
+ commands = ['upload', 'patch', 'queue', 'retry', 'schedule', 'update', 'log', 'run', 'install', 'webhook', 'info', 'stacks']
45
45
 
46
46
  if $*.size == 0 || (not commands.include?($*[0]))
47
47
  puts 'usage: iron_worker COMMAND [OPTIONS]'
@@ -315,7 +315,7 @@ elsif command == 'run'
315
315
  opts.on('--worker-config CONFIG_FILE', 'config file for worker') do |v|
316
316
  options[:worker_config] = v
317
317
  end
318
-
318
+
319
319
  common_opts(opts)
320
320
  end
321
321
 
@@ -469,4 +469,44 @@ elsif command == 'info'
469
469
 
470
470
  elsif command == 'stacks'
471
471
  @cli.stacks_list
472
+ elsif command == 'update'
473
+ entities = ['schedule']
474
+
475
+ if $*.size == 0 || (not entities.include?($*[0]))
476
+ puts 'usage: iron_worker update ENTITY [OPTIONS]'
477
+ puts " ENTITY: #{entities.join(', ')}"
478
+ puts ' run iron_worker update ENTITY --help to get more information about each entity'
479
+ exit 1
480
+ end
481
+
482
+ entity = $*.shift
483
+
484
+ if entity == 'schedule'
485
+ params = {}
486
+
487
+ opts = OptionParser.new do |opts|
488
+ opts.banner = "usage: iron_worker update schedule SCHEDULED_TASK_ID [OPTIONS]"
489
+
490
+ opts.on('-s', '--schedule SCHEDULE', String, 'schedule params to pass, JSON string') do |v|
491
+ params[:schedule] = v
492
+ end
493
+
494
+ common_opts(opts)
495
+ end
496
+
497
+ begin
498
+ opts.parse!
499
+ rescue OptionParser::ParseError
500
+ puts $!.to_s
501
+ exit 1
502
+ end
503
+
504
+ unless $*.size == 1
505
+ puts 'Please specify scheduled task id'
506
+ puts opts
507
+ exit 1
508
+ end
509
+
510
+ @cli.update_schedule($*[0], params)
511
+ end
472
512
  end
@@ -122,6 +122,11 @@ module IronWorkerNG
122
122
  parse_response(post("projects/#{@project_id}/schedules", {:schedules => [{:code_name => code_name, :payload => payload}.merge(options)]}))
123
123
  end
124
124
 
125
+ def schedules_update(id, options = {})
126
+ check_id(id)
127
+ parse_response(put("projects/#{@project_id}/schedules/#{id}", options))
128
+ end
129
+
125
130
  def schedules_cancel(id)
126
131
  check_id(id)
127
132
  parse_response(post("projects/#{@project_id}/schedules/#{id}/cancel"))
@@ -167,6 +167,21 @@ module IronWorkerNG
167
167
  end
168
168
  end
169
169
 
170
+ def update_schedule(schedule_id, params)
171
+ client
172
+
173
+ log_group "Updating scheduled task with id=#{schedule_id}"
174
+
175
+ response = client.schedules.update(schedule_id, JSON.parse(params[:schedule], :symbolize_names => true))
176
+
177
+ if response.msg == 'Updated'
178
+ log 'Scheduled task updated successfully'
179
+ log "Check 'https://hud.iron.io/tq/projects/#{client.api.project_id}/scheduled_jobs/#{schedule_id}' for more info"
180
+ else
181
+ log 'Something went wrong'
182
+ end
183
+ end
184
+
170
185
  def getlog(task_id, params, options)
171
186
  client
172
187
 
@@ -214,7 +229,7 @@ module IronWorkerNG
214
229
 
215
230
  log "Code package name is '#{code.name}'"
216
231
  log_group "Running '#{code.name}'"
217
-
232
+
218
233
  if options[:worker_config]
219
234
  log "Loading worker_config at #{options[:worker_config]}"
220
235
  c = IO.read(options[:worker_config])
@@ -394,6 +394,14 @@ EXEC_FILE
394
394
  OpenStruct.new(s)
395
395
  end
396
396
 
397
+ def schedules_update(id, options = {})
398
+ IronCore::Logger.debug 'IronWorkerNG', "Calling schedules.update with id='#{id}', options='#{options.to_s}'"
399
+
400
+ res = @api.schedules_update(id, options)
401
+
402
+ OpenStruct.new(res)
403
+ end
404
+
397
405
  def schedules_create_legacy(code_name, params = {}, options = {})
398
406
  IronCore::Logger.debug 'IronWorkerNG', "Calling schedules.create_legacy with code_name='#{code_name}', params='#{params.to_s}' and options='#{options.to_s}'"
399
407
 
@@ -1,5 +1,5 @@
1
1
  module IronWorkerNG
2
- VERSION = '1.5.1'
2
+ VERSION = '1.5.2'
3
3
 
4
4
  def self.version
5
5
  VERSION
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iron_worker_ng
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kirilenko
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-10-20 00:00:00.000000000 Z
12
+ date: 2014-11-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: iron_core