diff --git a/lib/fog/storm_on_demand/dns.rb b/lib/fog/storm_on_demand/dns.rb index 7d98ddced..f68876c46 100644 --- a/lib/fog/storm_on_demand/dns.rb +++ b/lib/fog/storm_on_demand/dns.rb @@ -14,10 +14,18 @@ module Fog model_path 'fog/storm_on_demand/models/dns' model :domain collection :domains + model :record + collection :records request_path 'fog/storm_on_demand/requests/dns' request :list_domains request :renew_domain + + request :create_record + request :delete_record + request :get_record + request :list_records + request :update_record class Mock diff --git a/lib/fog/storm_on_demand/models/dns/record.rb b/lib/fog/storm_on_demand/models/dns/record.rb new file mode 100644 index 000000000..8b8729bfa --- /dev/null +++ b/lib/fog/storm_on_demand/models/dns/record.rb @@ -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 diff --git a/lib/fog/storm_on_demand/models/dns/records.rb b/lib/fog/storm_on_demand/models/dns/records.rb new file mode 100644 index 000000000..82f2e1a98 --- /dev/null +++ b/lib/fog/storm_on_demand/models/dns/records.rb @@ -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 diff --git a/lib/fog/storm_on_demand/requests/dns/create_record.rb b/lib/fog/storm_on_demand/requests/dns/create_record.rb new file mode 100644 index 000000000..fd3640247 --- /dev/null +++ b/lib/fog/storm_on_demand/requests/dns/create_record.rb @@ -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 diff --git a/lib/fog/storm_on_demand/requests/dns/delete_record.rb b/lib/fog/storm_on_demand/requests/dns/delete_record.rb new file mode 100644 index 000000000..0f1eb34f6 --- /dev/null +++ b/lib/fog/storm_on_demand/requests/dns/delete_record.rb @@ -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 diff --git a/lib/fog/storm_on_demand/requests/dns/get_record.rb b/lib/fog/storm_on_demand/requests/dns/get_record.rb new file mode 100644 index 000000000..9a95dfdb2 --- /dev/null +++ b/lib/fog/storm_on_demand/requests/dns/get_record.rb @@ -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 diff --git a/lib/fog/storm_on_demand/requests/dns/list_records.rb b/lib/fog/storm_on_demand/requests/dns/list_records.rb new file mode 100644 index 000000000..10b91423d --- /dev/null +++ b/lib/fog/storm_on_demand/requests/dns/list_records.rb @@ -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 diff --git a/lib/fog/storm_on_demand/requests/dns/update_record.rb b/lib/fog/storm_on_demand/requests/dns/update_record.rb new file mode 100644 index 000000000..05de854a7 --- /dev/null +++ b/lib/fog/storm_on_demand/requests/dns/update_record.rb @@ -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