From df73f445d7f71d1d64b646959c6a03127b3a378f Mon Sep 17 00:00:00 2001 From: Kevin Olbrich Date: Thu, 12 Dec 2013 19:44:51 +0000 Subject: [PATCH] create instrumentations, handle errors better, get an individual instrumentation --- lib/fog/joyent/analytics.rb | 5 +++++ lib/fog/joyent/compute.rb | 3 +++ lib/fog/joyent/models/analytics/instrumentations.rb | 5 +++++ lib/fog/joyent/requests/analytics/create_instrumentation.rb | 0 lib/fog/joyent/requests/analytics/get_instrumentation.rb | 0 5 files changed, 13 insertions(+) create mode 100644 lib/fog/joyent/requests/analytics/create_instrumentation.rb create mode 100644 lib/fog/joyent/requests/analytics/get_instrumentation.rb diff --git a/lib/fog/joyent/analytics.rb b/lib/fog/joyent/analytics.rb index 3ac2834b6..1ec771e69 100644 --- a/lib/fog/joyent/analytics.rb +++ b/lib/fog/joyent/analytics.rb @@ -18,6 +18,8 @@ module Fog request :describe_analytics request :list_instrumentations + request :get_instrumentation + request :create_instrumentation model_path 'fog/joyent/models/analytics' @@ -132,6 +134,9 @@ module Fog response rescue Excon::Errors::HTTPStatusError => e + if e.response.headers["Content-Type"] == "application/json" + e.response.body = json_decode(e.response.body) + end raise_if_error!(e.request, e.response) end diff --git a/lib/fog/joyent/compute.rb b/lib/fog/joyent/compute.rb index 212553e9a..1dd062c1b 100644 --- a/lib/fog/joyent/compute.rb +++ b/lib/fog/joyent/compute.rb @@ -173,6 +173,9 @@ module Fog response rescue Excon::Errors::HTTPStatusError => e + if e.response.headers["Content-Type"] == "application/json" + e.response.body = json_decode(e.response.body) + end raise_if_error!(e.request, e.response) end diff --git a/lib/fog/joyent/models/analytics/instrumentations.rb b/lib/fog/joyent/models/analytics/instrumentations.rb index b0b2d2a6b..429cba0b1 100644 --- a/lib/fog/joyent/models/analytics/instrumentations.rb +++ b/lib/fog/joyent/models/analytics/instrumentations.rb @@ -12,6 +12,11 @@ module Fog load(data) end + def get(id) + data = service.get_instrumentation(id).body + new(data) + end + end end end diff --git a/lib/fog/joyent/requests/analytics/create_instrumentation.rb b/lib/fog/joyent/requests/analytics/create_instrumentation.rb new file mode 100644 index 000000000..e69de29bb diff --git a/lib/fog/joyent/requests/analytics/get_instrumentation.rb b/lib/fog/joyent/requests/analytics/get_instrumentation.rb new file mode 100644 index 000000000..e69de29bb