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:
parent
767e18225a
commit
1a8ddf379b
7 changed files with 135 additions and 0 deletions
|
@ -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
|
||||
|
@ -123,6 +125,11 @@ module Fog
|
|||
request :get_product_price
|
||||
request :get_product_starting_price
|
||||
|
||||
request :list_notifications
|
||||
request :current_notifications
|
||||
request :get_notification
|
||||
request :resolve_notification
|
||||
|
||||
class Mock
|
||||
|
||||
def self.data
|
||||
|
|
34
lib/fog/storm_on_demand/models/compute/notification.rb
Normal file
34
lib/fog/storm_on_demand/models/compute/notification.rb
Normal 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
|
30
lib/fog/storm_on_demand/models/compute/notifications.rb
Normal file
30
lib/fog/storm_on_demand/models/compute/notifications.rb
Normal 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
|
|
@ -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
|
16
lib/fog/storm_on_demand/requests/compute/get_notification.rb
Normal file
16
lib/fog/storm_on_demand/requests/compute/get_notification.rb
Normal 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
|
|
@ -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
|
|
@ -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
|
Loading…
Add table
Reference in a new issue