Class: Nrcmd::User

Inherits:
Thor
  • Object
show all
Defined in:
lib/nrcmd/users_cli.rb

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

#listObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/nrcmd/users_cli.rb', line 17

def list
  uri = URL + '/users.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 ]
end

#show(id) ⇒ Object



33
34
35
36
37
38
# File 'lib/nrcmd/users_cli.rb', line 33

def show(id)
  uri = URL + "/users/#{id}.json"
  res = Nrcmd::Http.get(uri)
  result = JSON.parse(res.body)
  print JSON[ result ]
end