Class: SchwarmCli::Commands::Recurring
- Inherits:
-
Base
- Object
- Thor
- Base
- SchwarmCli::Commands::Recurring
show all
- Defined in:
- lib/schwarm_cli/commands/recurring.rb
Constant Summary
Constants inherited
from Base
Base::DEFAULT_LIST_LIMIT, Base::INHERITED_OPTIONS
Instance Method Summary
collapse
Methods inherited from Base
exit_on_failure?, pagination_options
Instance Method Details
#create ⇒ Object
35
36
37
38
39
40
|
# File 'lib/schwarm_cli/commands/recurring.rb', line 35
def create
handle_errors do
data = client.recurring.create(**create_attrs)
output_record(data, fields: recurring_fields)
end
end
|
#delete(id) ⇒ Object
54
55
56
57
58
59
|
# File 'lib/schwarm_cli/commands/recurring.rb', line 54
def delete(id)
handle_errors do
client.recurring.destroy(id)
puts "Recurring task #{id} deleted."
end
end
|
#list ⇒ Object
10
11
12
13
14
15
16
17
18
|
# File 'lib/schwarm_cli/commands/recurring.rb', line 10
def list
handle_errors do
data = fetch_paged do |page_params|
client.recurring.list(repository_id: resolve_repo(options[:repo]), query: options[:query], **page_params)
end
output_list(data, columns: [%w[ID id], %w[NAME name], %w[REPO github_repository_name],
%w[ENABLED enabled], %w[SCHEDULE cron_expression]])
end
end
|
#show(id) ⇒ Object
21
22
23
24
25
26
|
# File 'lib/schwarm_cli/commands/recurring.rb', line 21
def show(id)
handle_errors do
data = client.recurring.find(id)
output_record(data, fields: recurring_fields)
end
end
|
#toggle(id) ⇒ Object
62
63
64
65
66
67
68
|
# File 'lib/schwarm_cli/commands/recurring.rb', line 62
def toggle(id)
handle_errors do
data = client.recurring.toggle(id)
status = data.dig("data", "enabled") ? "enabled" : "disabled"
puts "Recurring task #{id} #{status}."
end
end
|
#update(id) ⇒ Object
46
47
48
49
50
51
|
# File 'lib/schwarm_cli/commands/recurring.rb', line 46
def update(id)
handle_errors do
data = client.recurring.update(id, **update_attrs)
output_record(data, fields: recurring_fields)
end
end
|