From 55d328b28377548d9b751d67701cd8e93e96363b Mon Sep 17 00:00:00 2001 From: Kevin Olbrich Date: Thu, 12 Dec 2013 17:17:01 +0000 Subject: [PATCH] describe analytics support --- .../joyent/models/analytics/joyent_module.rb | 2 ++ .../joyent/models/analytics/joyent_modules.rb | 27 +++++++++++++++++++ .../requests/analytics/describe_analytics.rb | 15 +++++++++++ 3 files changed, 44 insertions(+) diff --git a/lib/fog/joyent/models/analytics/joyent_module.rb b/lib/fog/joyent/models/analytics/joyent_module.rb index 2fe6fe549..4eab489f0 100644 --- a/lib/fog/joyent/models/analytics/joyent_module.rb +++ b/lib/fog/joyent/models/analytics/joyent_module.rb @@ -6,7 +6,9 @@ module Fog module Joyent class Analytics class JoyentModule < Fog::Model + attribute :name attribute :label + end end end diff --git a/lib/fog/joyent/models/analytics/joyent_modules.rb b/lib/fog/joyent/models/analytics/joyent_modules.rb index e69de29bb..fdf7fac78 100644 --- a/lib/fog/joyent/models/analytics/joyent_modules.rb +++ b/lib/fog/joyent/models/analytics/joyent_modules.rb @@ -0,0 +1,27 @@ +require 'fog/joyent/models/analytics/joyent_module' + +module Fog + module Joyent + class Analytics + class JoyentModules < Fog::Collection + + model Fog::Joyent::Analytics::JoyentModule + + def all + data = service.describe_analytics.body['modules'] + load(data) + end + + # Joyent returns an odd data structure like this: + # { 'apache' => {'label' => 'Apache'}} + # where the key is the name of the module + def new(attributes = {}) + puts attributes.inspect + name, other_attributes = attributes + super(other_attributes.merge('name' => name)) + end + + end + end + end +end diff --git a/lib/fog/joyent/requests/analytics/describe_analytics.rb b/lib/fog/joyent/requests/analytics/describe_analytics.rb index e69de29bb..daf134f08 100644 --- a/lib/fog/joyent/requests/analytics/describe_analytics.rb +++ b/lib/fog/joyent/requests/analytics/describe_analytics.rb @@ -0,0 +1,15 @@ +module Fog + module Joyent + class Analytics + class Real + def describe_analytics + request( + :path => "#{@joyent_username}/analytics", + :method => "GET", + :expects => 200 + ) + end + end + end + end +end