Class: Nrcmd::Apps::Hosts

Inherits:
Thor
  • Object
show all
Defined in:
lib/nrcmd/apps/hosts/cli.rb

Defined Under Namespace

Classes: Metrics

Constant Summary collapse

URL =
'https://api.newrelic.com/v2'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details



44
45
46
# File 'lib/nrcmd/apps/hosts/cli.rb', line 44

def self.banner(task, namespace = false, subcommand = true)
  super
end

Instance Method Details

#list(app_id) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/nrcmd/apps/hosts/cli.rb', line 22

def list(app_id)
  uri = URL + "/applications/#{app_id}/hosts.json"
  filter_param = ""
  options["filter"].gsub(" ", "").split(',').each do |filter|
    fkv = filter.split('=')
    filter_param << "filter[#{fkv[0]}]=#{fkv[1]}&"
  end
  res = Nrcmd::Http.get(uri, {}, filter_param)
  result = JSON.parse(res.body)
  print JSON[ result["application_hosts"] ]
end

#show(app_id, host_id) ⇒ Object



38
39
40
41
42
43
# File 'lib/nrcmd/apps/hosts/cli.rb', line 38

def show(app_id, host_id)
  uri = URL + "/applications/#{app_id}/hosts/#{host_id}.json"
  res = Nrcmd::Http.get(uri)
  result = JSON.parse(res.body)
  print JSON[ result["application_host"]]
end