1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[stormnondemand|compute] Add Notification APIs

This commit is contained in:
Eric Wong 2013-05-23 22:29:42 +08:00
parent 767e18225a
commit 1a8ddf379b
7 changed files with 135 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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