Class: Nrcmd::Apps
- Inherits:
-
Thor
- Object
- Thor
- Nrcmd::Apps
- Defined in:
- lib/nrcmd/apps/cli.rb
Defined Under Namespace
Constant Summary collapse
- URL =
'https://api.newrelic.com/v2'
Instance Method Summary collapse
Instance Method Details
#__delete(id) ⇒ Object
83 84 85 86 87 88 |
# File 'lib/nrcmd/apps/cli.rb', line 83 def __delete(id) uri = URL + "/applications/#{id}.json" res = Nrcmd::Http.delete(uri) result = JSON.parse(res.body) print JSON[ result ] end |
#list ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/nrcmd/apps/cli.rb', line 22 def list uri = URL + '/applications.json' filter_param = "" ["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["applications"] ] end |
#show(app_id) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/nrcmd/apps/cli.rb', line 38 def show(app_id) uri = URL + "/applications/#{app_id}.json" res = Nrcmd::Http.get(uri) result = JSON.parse(res.body) print JSON[ result["application"]] end |
#update(app_id, json_param) ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/nrcmd/apps/cli.rb', line 70 def update(app_id, json_param) uri = URL + "/applications/#{app_id}.json" header = { 'Content-Type' => 'application/json' } data = json_param res = Nrcmd::Http.put(uri, header, data) result = JSON.parse(res.body) print JSON[ result ] end |