From 1a8ddf379b43be880fcaf718c15b5ba6b21d1e8c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 23 May 2013 22:29:42 +0800 Subject: [PATCH] [stormnondemand|compute] Add Notification APIs --- lib/fog/storm_on_demand/compute.rb | 7 ++++ .../models/compute/notification.rb | 34 +++++++++++++++++++ .../models/compute/notifications.rb | 30 ++++++++++++++++ .../requests/compute/current_notifications.rb | 16 +++++++++ .../requests/compute/get_notification.rb | 16 +++++++++ .../requests/compute/list_notifications.rb | 16 +++++++++ .../requests/compute/resolve_notification.rb | 16 +++++++++ 7 files changed, 135 insertions(+) create mode 100644 lib/fog/storm_on_demand/models/compute/notification.rb create mode 100644 lib/fog/storm_on_demand/models/compute/notifications.rb create mode 100644 lib/fog/storm_on_demand/requests/compute/current_notifications.rb create mode 100644 lib/fog/storm_on_demand/requests/compute/get_notification.rb create mode 100644 lib/fog/storm_on_demand/requests/compute/list_notifications.rb create mode 100644 lib/fog/storm_on_demand/requests/compute/resolve_notification.rb diff --git a/lib/fog/storm_on_demand/compute.rb b/lib/fog/storm_on_demand/compute.rb index 150df3370..5afeb0a8f 100644 --- a/lib/fog/storm_on_demand/compute.rb +++ b/lib/fog/storm_on_demand/compute.rb @@ -38,6 +38,8 @@ module Fog collection :templates model :product collection :products + model :notification + collection :notifications request_path 'fog/storm_on_demand/requests/compute' request :clone_server @@ -122,6 +124,11 @@ module Fog request :list_products request :get_product_price request :get_product_starting_price + + request :list_notifications + request :current_notifications + request :get_notification + request :resolve_notification class Mock diff --git a/lib/fog/storm_on_demand/models/compute/notification.rb b/lib/fog/storm_on_demand/models/compute/notification.rb new file mode 100644 index 000000000..5f7b19e50 --- /dev/null +++ b/lib/fog/storm_on_demand/models/compute/notification.rb @@ -0,0 +1,34 @@ +require 'fog/core/model' + +module Fog + module Compute + class StormOnDemand + + class Notification < Fog::Model + identity :id + attribute :category + attribute :description + attribute :enddate + attribute :last_alert + attribute :modifieddate + attribute :resolved + attribute :severity + attribute :startdate + attribute :system + attribute :system_identifier + attribute :uniq_id + + def initialize(attributes={}) + super + end + + def resolve + requires :identity + service.resolve_notification(:id => identity) + end + + end + + end + end +end diff --git a/lib/fog/storm_on_demand/models/compute/notifications.rb b/lib/fog/storm_on_demand/models/compute/notifications.rb new file mode 100644 index 000000000..7cc37cb7b --- /dev/null +++ b/lib/fog/storm_on_demand/models/compute/notifications.rb @@ -0,0 +1,30 @@ +require 'fog/core/collection' +require 'fog/storm_on_demand/models/compute/notification' + +module Fog + module Compute + class StormOnDemand + + class Notifications < Fog::Collection + model Fog::Compute::StormOnDemand::Notification + + def all(options={}) + data = service.list_notifications(options).body['items'] + load(data) + end + + def current(options={}) + data = service.current_notifications(options).body['items'] + load(data) + end + + def get(options) + data = service.get_notification(options).body + new(data) + end + + end + + end + end +end diff --git a/lib/fog/storm_on_demand/requests/compute/current_notifications.rb b/lib/fog/storm_on_demand/requests/compute/current_notifications.rb new file mode 100644 index 000000000..f7a6a9dea --- /dev/null +++ b/lib/fog/storm_on_demand/requests/compute/current_notifications.rb @@ -0,0 +1,16 @@ +module Fog + module Compute + class StormOnDemand + class Real + + def current_notifications(options={}) + request( + :path => '/Notifications/current', + :body => Fog::JSON.encode(:params => options) + ) + end + + end + end + end +end diff --git a/lib/fog/storm_on_demand/requests/compute/get_notification.rb b/lib/fog/storm_on_demand/requests/compute/get_notification.rb new file mode 100644 index 000000000..2723ce7a0 --- /dev/null +++ b/lib/fog/storm_on_demand/requests/compute/get_notification.rb @@ -0,0 +1,16 @@ +module Fog + module Compute + class StormOnDemand + class Real + + def get_notification(options={}) + request( + :path => '/Notifications/details', + :body => Fog::JSON.encode(:params => options) + ) + end + + end + end + end +end diff --git a/lib/fog/storm_on_demand/requests/compute/list_notifications.rb b/lib/fog/storm_on_demand/requests/compute/list_notifications.rb new file mode 100644 index 000000000..19470526c --- /dev/null +++ b/lib/fog/storm_on_demand/requests/compute/list_notifications.rb @@ -0,0 +1,16 @@ +module Fog + module Compute + class StormOnDemand + class Real + + def list_notifications(options={}) + request( + :path => '/Notifications/all', + :body => Fog::JSON.encode(:params => options) + ) + end + + end + end + end +end diff --git a/lib/fog/storm_on_demand/requests/compute/resolve_notification.rb b/lib/fog/storm_on_demand/requests/compute/resolve_notification.rb new file mode 100644 index 000000000..881b52269 --- /dev/null +++ b/lib/fog/storm_on_demand/requests/compute/resolve_notification.rb @@ -0,0 +1,16 @@ +module Fog + module Compute + class StormOnDemand + class Real + + def resolve_notification(options={}) + request( + :path => '/Notifications/resolve', + :body => Fog::JSON.encode(:params => options) + ) + end + + end + end + end +end