Class: Ruzbx::Tasks::Jira
- Inherits:
-
Object
- Object
- Ruzbx::Tasks::Jira
- Includes:
- Rake::DSL
- Defined in:
- lib/ruzbx/tasks/zabbix.rb
Overview
TODO
Instance Method Summary collapse
-
#define ⇒ Object
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength.
-
#generate(name, &block) ⇒ Object
rubocop:enable Metrics/AbcSize rubocop:enable Metrics/MethodLength.
-
#initialize ⇒ Jira
constructor
A new instance of Jira.
- #options(name) ⇒ Object
- #parser ⇒ Object
Constructor Details
#initialize ⇒ Jira
Returns a new instance of Jira.
13 14 15 16 17 18 19 |
# File 'lib/ruzbx/tasks/zabbix.rb', line 13 def initialize = { issuetype: 'Task' } @parser = OptionParser.new define end |
Instance Method Details
#define ⇒ Object
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/ruzbx/tasks/zabbix.rb', line 33 def define generate 'whoami' do puts Ruzbx::Api::Myself.get.name end generate 'url' do puts Ruzbx::Configuration.url end generate 'server_info' do puts Ruzbx::Api::ServerInfo.get.data.to_json end generate 'template' do parser do @parser. = "Usage: rake zabbix:template -- '[options]'" @parser.on('-n NAME', '--name=NAME') { |name| [:name] = name } end = result = Ruzbx::Api::Template.get [:name] result.data['result'].each { |i| puts JSON.pretty_generate(i) } end generate 'create' do parser do @parser. = "Usage: rake zabbix:create -- '[options]'" @parser.on('-n NAME', '--name=NAME') { |name| [:name] = name.strip } @parser.on('-i IP', '--ip=NAME') { |ip| [:ip] = ip } @parser.on('-t NAME', '--templates=NAME') { |templates| [:templates] = templates.strip.split(',') } @parser.on('-g NAME', '--hostgroups=NAME') do |hostgroups| [:hostgroups] = hostgroups.strip.split(',') end end = [:templates] = Ruzbx::Api::Template.get([:templates]).ids.map do |i| { templateid: i } end [:groups] = Ruzbx::Api::HostGroup.get([:hostgroups]).ids.map do |i| { groupid: i } end result = Ruzbx::Api::Host.create result.data['result'].each { |i| puts JSON.pretty_generate(i) } end end |
#generate(name, &block) ⇒ Object
rubocop:enable Metrics/AbcSize rubocop:enable Metrics/MethodLength
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/ruzbx/tasks/zabbix.rb', line 78 def generate(name, &block) fullname = "zabbix:#{name}" desc "Run #{fullname}" Rake::Task[fullname].clear if Rake::Task.task_defined?(fullname) namespace :zabbix do task name do instance_eval(&block) end end end |
#options(name) ⇒ Object
27 28 29 |
# File 'lib/ruzbx/tasks/zabbix.rb', line 27 def (name) [name] end |
#parser ⇒ Object
21 22 23 24 25 |
# File 'lib/ruzbx/tasks/zabbix.rb', line 21 def parser yield args = @parser.order!(ARGV) {} @parser.parse!(args) end |