mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[stormondemand|dns] Add DNS record APIs
This commit is contained in:
parent
a1982511e1
commit
d8f7c9efbf
8 changed files with 166 additions and 0 deletions
|
@ -14,10 +14,18 @@ module Fog
|
||||||
model_path 'fog/storm_on_demand/models/dns'
|
model_path 'fog/storm_on_demand/models/dns'
|
||||||
model :domain
|
model :domain
|
||||||
collection :domains
|
collection :domains
|
||||||
|
model :record
|
||||||
|
collection :records
|
||||||
|
|
||||||
request_path 'fog/storm_on_demand/requests/dns'
|
request_path 'fog/storm_on_demand/requests/dns'
|
||||||
request :list_domains
|
request :list_domains
|
||||||
request :renew_domain
|
request :renew_domain
|
||||||
|
|
||||||
|
request :create_record
|
||||||
|
request :delete_record
|
||||||
|
request :get_record
|
||||||
|
request :list_records
|
||||||
|
request :update_record
|
||||||
|
|
||||||
class Mock
|
class Mock
|
||||||
|
|
||||||
|
|
48
lib/fog/storm_on_demand/models/dns/record.rb
Normal file
48
lib/fog/storm_on_demand/models/dns/record.rb
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
require 'fog/core/model'
|
||||||
|
|
||||||
|
module Fog
|
||||||
|
module DNS
|
||||||
|
class StormOnDemand
|
||||||
|
|
||||||
|
class Record < Fog::Model
|
||||||
|
identity :id
|
||||||
|
attribute :adminEmail
|
||||||
|
attribute :expiry
|
||||||
|
attribute :fullData
|
||||||
|
attribute :minimum
|
||||||
|
attribute :name
|
||||||
|
attribute :nameserver
|
||||||
|
attribute :port
|
||||||
|
attribute :prio
|
||||||
|
attribute :rdata
|
||||||
|
attribute :refreshInterval
|
||||||
|
attribute :regionOverrides
|
||||||
|
attribute :retry
|
||||||
|
attribute :serial
|
||||||
|
attribute :target
|
||||||
|
attribute :ttl
|
||||||
|
attribute :type
|
||||||
|
attribute :weight
|
||||||
|
attribute :zone_id
|
||||||
|
|
||||||
|
def initialize(attributes={})
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
requires :identity
|
||||||
|
service.delete_record(:id => identity)
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
|
def update(options={})
|
||||||
|
requires :identity
|
||||||
|
service.update_record({:id => identity}.merge!(options))
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
30
lib/fog/storm_on_demand/models/dns/records.rb
Normal file
30
lib/fog/storm_on_demand/models/dns/records.rb
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
require 'fog/core/collection'
|
||||||
|
require 'fog/storm_on_demand/models/dns'
|
||||||
|
|
||||||
|
module Fog
|
||||||
|
module DNS
|
||||||
|
class StormOnDemand
|
||||||
|
|
||||||
|
class Records < Fog::Collection
|
||||||
|
model Fog::DNS::StormOnDemand::Record
|
||||||
|
|
||||||
|
def create(options)
|
||||||
|
rec = service.create_record(options).body
|
||||||
|
new(rec)
|
||||||
|
end
|
||||||
|
|
||||||
|
def get(record_id)
|
||||||
|
rec = service.get_record(:id => record_id).body
|
||||||
|
new(rec)
|
||||||
|
end
|
||||||
|
|
||||||
|
def all(options={})
|
||||||
|
recs = service.list_records(options).body['items']
|
||||||
|
load(recs)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
16
lib/fog/storm_on_demand/requests/dns/create_record.rb
Normal file
16
lib/fog/storm_on_demand/requests/dns/create_record.rb
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
module Fog
|
||||||
|
module DNS
|
||||||
|
class StormOnDemand
|
||||||
|
class Real
|
||||||
|
|
||||||
|
def create_record(options={})
|
||||||
|
request(
|
||||||
|
:path => '/Network/DNS/Record/create',
|
||||||
|
:body => Fog::JSON.encode(:params => options)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
16
lib/fog/storm_on_demand/requests/dns/delete_record.rb
Normal file
16
lib/fog/storm_on_demand/requests/dns/delete_record.rb
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
module Fog
|
||||||
|
module DNS
|
||||||
|
class StormOnDemand
|
||||||
|
class Real
|
||||||
|
|
||||||
|
def delete_record(options={})
|
||||||
|
request(
|
||||||
|
:path => '/Network/DNS/Record/delete',
|
||||||
|
:body => Fog::JSON.encode(:params => options)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
16
lib/fog/storm_on_demand/requests/dns/get_record.rb
Normal file
16
lib/fog/storm_on_demand/requests/dns/get_record.rb
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
module Fog
|
||||||
|
module DNS
|
||||||
|
class StormOnDemand
|
||||||
|
class Real
|
||||||
|
|
||||||
|
def get_record(options={})
|
||||||
|
request(
|
||||||
|
:path => '/Network/DNS/Record/details',
|
||||||
|
:body => Fog::JSON.encode(:params => options)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
16
lib/fog/storm_on_demand/requests/dns/list_records.rb
Normal file
16
lib/fog/storm_on_demand/requests/dns/list_records.rb
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
module Fog
|
||||||
|
module DNS
|
||||||
|
class StormOnDemand
|
||||||
|
class Real
|
||||||
|
|
||||||
|
def list_records(options={})
|
||||||
|
request(
|
||||||
|
:path => '/Network/DNS/Record/list',
|
||||||
|
:body => Fog::JSON.encode(:params => options)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
16
lib/fog/storm_on_demand/requests/dns/update_record.rb
Normal file
16
lib/fog/storm_on_demand/requests/dns/update_record.rb
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
module Fog
|
||||||
|
module DNS
|
||||||
|
class StormOnDemand
|
||||||
|
class Real
|
||||||
|
|
||||||
|
def update_record(options={})
|
||||||
|
request(
|
||||||
|
:path => '/Network/DNS/Record/update',
|
||||||
|
:body => Fog::JSON.encode(:params => options)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Reference in a new issue