mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[stormondemand|support] Add Support service and APIs for alert and support tickets
This commit is contained in:
parent
55d0925de1
commit
5f44aa8498
18 changed files with 417 additions and 0 deletions
|
@ -10,6 +10,7 @@ module Fog
|
|||
service(:dns, 'storm_on_demand/dns', 'DNS')
|
||||
service(:billing, 'storm_on_demand/billing', 'Billing')
|
||||
service(:monitoring, 'storm_on_demand/monitoring', 'Monitoring')
|
||||
service(:support, 'storm_on_demand/support', 'Support')
|
||||
|
||||
end
|
||||
end
|
||||
|
|
19
lib/fog/storm_on_demand/models/support/alert.rb
Normal file
19
lib/fog/storm_on_demand/models/support/alert.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Support
|
||||
class StormOnDemand
|
||||
|
||||
class Alert < Fog::Model
|
||||
attribute :message
|
||||
attribute :subject
|
||||
|
||||
def initialize(attributes={})
|
||||
super
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
20
lib/fog/storm_on_demand/models/support/alerts.rb
Normal file
20
lib/fog/storm_on_demand/models/support/alerts.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/storm_on_demand/models/support/alert'
|
||||
|
||||
module Fog
|
||||
module Support
|
||||
class StormOnDemand
|
||||
|
||||
class Alerts < Fog::Collection
|
||||
model Fog::Support::StormOnDemand::Alert
|
||||
|
||||
def get_active
|
||||
alert = service.get_active_alert.body['active_alert']
|
||||
new(alert)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
74
lib/fog/storm_on_demand/models/support/ticket.rb
Normal file
74
lib/fog/storm_on_demand/models/support/ticket.rb
Normal file
|
@ -0,0 +1,74 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Support
|
||||
class StormOnDemand
|
||||
|
||||
class Ticket < Fog::Model
|
||||
identity :id
|
||||
attribute :accnt
|
||||
attribute :account
|
||||
attribute :body
|
||||
attribute :closed
|
||||
attribute :email
|
||||
attribute :handler
|
||||
attribute :last_responded
|
||||
attribute :received
|
||||
attribute :secid
|
||||
attribute :status
|
||||
attribute :subject
|
||||
attribute :type
|
||||
|
||||
def initialize(attributes={})
|
||||
super
|
||||
end
|
||||
|
||||
def add_feedback(options)
|
||||
requires :identity
|
||||
res = service.add_feedback({:id => identity}.merge!(options)).body
|
||||
res['feedback'].to_i == 1 ? true : false
|
||||
end
|
||||
|
||||
def add_transaction_feedback(options)
|
||||
requires :identity
|
||||
requires :secid
|
||||
params = {:ticket_id => identity,
|
||||
:secid => secid}.merge!(options)
|
||||
service.add_transaction_feedback(params).body
|
||||
end
|
||||
|
||||
def authenticate(options)
|
||||
requires :identity
|
||||
requires :secid
|
||||
params = {:id => identity, :secid => secid}.merge!(options)
|
||||
service.authenticate(params).body
|
||||
end
|
||||
|
||||
def close
|
||||
requires :identity
|
||||
requires :secid
|
||||
res = service.close_ticket(:id => identity, :secid => secid).body
|
||||
res['closed'].to_i == 1 ? true : false
|
||||
end
|
||||
|
||||
def reopen
|
||||
requires :identity
|
||||
requires :secid
|
||||
res = service.reopen_ticket(:id => identity, :secid => secid).body
|
||||
res['reopened'].to_i == 1 ? true : false
|
||||
end
|
||||
|
||||
def reply(options)
|
||||
requires :identity
|
||||
requires :secid
|
||||
res = service.reply_ticket({:id => identity,
|
||||
:secid => secid}.merge!(options)).body
|
||||
res['reply'].to_i == 1 ? true : false
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
33
lib/fog/storm_on_demand/models/support/tickets.rb
Normal file
33
lib/fog/storm_on_demand/models/support/tickets.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/storm_on_demand/models/support/ticket'
|
||||
|
||||
module Fog
|
||||
module Support
|
||||
class StormOnDemand
|
||||
|
||||
class Tickets < Fog::Collection
|
||||
model Fog::Support::StormOnDemand::Ticket
|
||||
|
||||
def create(options)
|
||||
ticket = service.create_ticket(options).body
|
||||
new(ticket)
|
||||
end
|
||||
|
||||
def get(ticket_id, secid)
|
||||
service.get_ticket_details(:id => ticket_id, :secid => secid).body
|
||||
end
|
||||
|
||||
def all(options={})
|
||||
tickets = service.list_tickets(options).body['items']
|
||||
load(tickets)
|
||||
end
|
||||
|
||||
def types
|
||||
service.list_ticket_types.body['types']
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
16
lib/fog/storm_on_demand/requests/support/add_feedback.rb
Normal file
16
lib/fog/storm_on_demand/requests/support/add_feedback.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
module Fog
|
||||
module Support
|
||||
class StormOnDemand
|
||||
class Real
|
||||
|
||||
def add_feedback(options={})
|
||||
request(
|
||||
:path => '/Support/Ticket/addFeedback',
|
||||
:body => Fog::JSON.encode(:params => options)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
module Fog
|
||||
module Support
|
||||
class StormOnDemand
|
||||
class Real
|
||||
|
||||
def add_transaction_feedback(options={})
|
||||
request(
|
||||
:path => '/Support/Ticket/addTransactionFeedback',
|
||||
:body => Fog::JSON.encode(:params => options)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
16
lib/fog/storm_on_demand/requests/support/authenticate.rb
Normal file
16
lib/fog/storm_on_demand/requests/support/authenticate.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
module Fog
|
||||
module Support
|
||||
class StormOnDemand
|
||||
class Real
|
||||
|
||||
def authenticate(options={})
|
||||
request(
|
||||
:path => '/Support/Ticket/authenticate',
|
||||
:body => Fog::JSON.encode(:params => options)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
16
lib/fog/storm_on_demand/requests/support/close_ticket.rb
Normal file
16
lib/fog/storm_on_demand/requests/support/close_ticket.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
module Fog
|
||||
module Support
|
||||
class StormOnDemand
|
||||
class Real
|
||||
|
||||
def close_ticket(options={})
|
||||
request(
|
||||
:path => '/Support/Ticket/close',
|
||||
:body => Fog::JSON.encode(:params => options)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
16
lib/fog/storm_on_demand/requests/support/create_ticket.rb
Normal file
16
lib/fog/storm_on_demand/requests/support/create_ticket.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
module Fog
|
||||
module Support
|
||||
class StormOnDemand
|
||||
class Real
|
||||
|
||||
def create_ticket(options={})
|
||||
request(
|
||||
:path => '/Support/Ticket/create',
|
||||
:body => Fog::JSON.encode(:params => options)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
16
lib/fog/storm_on_demand/requests/support/get_active_alert.rb
Normal file
16
lib/fog/storm_on_demand/requests/support/get_active_alert.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
module Fog
|
||||
module Support
|
||||
class StormOnDemand
|
||||
class Real
|
||||
|
||||
def get_active_alert(options={})
|
||||
request(
|
||||
:path => '/Support/Alert/getActive',
|
||||
:body => Fog::JSON.encode(:params => options)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
module Fog
|
||||
module Support
|
||||
class StormOnDemand
|
||||
class Real
|
||||
|
||||
def get_ticket_details(options={})
|
||||
request(
|
||||
:path => '/Support/Ticket/details',
|
||||
:body => Fog::JSON.encode(:params => options)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
module Fog
|
||||
module Support
|
||||
class StormOnDemand
|
||||
class Real
|
||||
|
||||
def list_ticket_types(options={})
|
||||
request(
|
||||
:path => '/Support/Ticket/types',
|
||||
:body => Fog::JSON.encode(:params => options)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
16
lib/fog/storm_on_demand/requests/support/list_tickets.rb
Normal file
16
lib/fog/storm_on_demand/requests/support/list_tickets.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
module Fog
|
||||
module Support
|
||||
class StormOnDemand
|
||||
class Real
|
||||
|
||||
def list_tickets(options={})
|
||||
request(
|
||||
:path => '/Support/Ticket/list',
|
||||
:body => Fog::JSON.encode(:params => options)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
16
lib/fog/storm_on_demand/requests/support/reopen_ticket.rb
Normal file
16
lib/fog/storm_on_demand/requests/support/reopen_ticket.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
module Fog
|
||||
module Support
|
||||
class StormOnDemand
|
||||
class Real
|
||||
|
||||
def reopen_ticket(options={})
|
||||
request(
|
||||
:path => '/Support/Ticket/reopen',
|
||||
:body => Fog::JSON.encode(:params => options)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
16
lib/fog/storm_on_demand/requests/support/reply_ticket.rb
Normal file
16
lib/fog/storm_on_demand/requests/support/reply_ticket.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
module Fog
|
||||
module Support
|
||||
class StormOnDemand
|
||||
class Real
|
||||
|
||||
def reply_ticket(options={})
|
||||
request(
|
||||
:path => '/Support/Ticket/reply',
|
||||
:body => Fog::JSON.encode(:params => options)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
68
lib/fog/storm_on_demand/support.rb
Normal file
68
lib/fog/storm_on_demand/support.rb
Normal file
|
@ -0,0 +1,68 @@
|
|||
require 'fog/storm_on_demand'
|
||||
require 'fog/support'
|
||||
require 'fog/storm_on_demand/shared'
|
||||
|
||||
module Fog
|
||||
module Support
|
||||
|
||||
class StormOnDemand < Fog::Service
|
||||
|
||||
requires :storm_on_demand_username, :storm_on_demand_password
|
||||
recognizes :storm_on_demand_auth_url
|
||||
|
||||
model_path 'fog/storm_on_demand/models/support'
|
||||
model :alert
|
||||
collection :alerts
|
||||
model :ticket
|
||||
collection :tickets
|
||||
|
||||
request_path 'fog/storm_on_demand/requests/support'
|
||||
request :get_active_alert
|
||||
request :add_feedback
|
||||
request :add_transaction_feedback
|
||||
request :authenticate
|
||||
request :close_ticket
|
||||
request :create_ticket
|
||||
request :get_ticket_details
|
||||
request :list_tickets
|
||||
request :reply_ticket
|
||||
request :list_ticket_types
|
||||
|
||||
class Mock
|
||||
|
||||
def self.data
|
||||
@data ||= Hash.new
|
||||
end
|
||||
|
||||
def self.reset
|
||||
@data = nil
|
||||
end
|
||||
|
||||
def self.reset_data(keys=data.keys)
|
||||
for key in [*keys]
|
||||
data.delete(key)
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(options={})
|
||||
@storm_on_demand_username = options[:storm_on_demand_username]
|
||||
end
|
||||
|
||||
def data
|
||||
self.class.data[@storm_on_demand_username]
|
||||
end
|
||||
|
||||
def reset_data
|
||||
self.class.data.delete(@storm_on_demand_username)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Real
|
||||
|
||||
include Fog::StormOnDemand::RealShared
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
26
lib/fog/support.rb
Normal file
26
lib/fog/support.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
module Fog
|
||||
module Support
|
||||
|
||||
def self.[](provider)
|
||||
self.new(:provider => provider)
|
||||
end
|
||||
|
||||
def self.new(attributes)
|
||||
attributes = attributes.dup
|
||||
provider = attributes.delete(:provider).to_s.downcase.to_sym
|
||||
|
||||
if provider == :stormondemand
|
||||
require 'fog/storm_on_demand/support'
|
||||
Fog::Support::StormOnDemand.new(attributes)
|
||||
else
|
||||
raise ArgumentError.new("#{provider} has no support service")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def self.providers
|
||||
Fog.services[:support]
|
||||
end
|
||||
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue