From 5bd1658876d09d1c3b3bdbd784f48f9e783d8450 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 23 May 2013 16:28:28 +0800 Subject: [PATCH] [stormondemand|dns] Add DNS Zone APIs --- lib/fog/storm_on_demand/dns.rb | 9 +++++ lib/fog/storm_on_demand/models/dns/domains.rb | 2 +- lib/fog/storm_on_demand/models/dns/records.rb | 2 +- lib/fog/storm_on_demand/models/dns/zone.rb | 40 +++++++++++++++++++ lib/fog/storm_on_demand/models/dns/zones.rb | 30 ++++++++++++++ .../requests/dns/check_zone_delegation.rb | 16 ++++++++ .../requests/dns/create_zone.rb | 16 ++++++++ .../requests/dns/delete_zone.rb | 16 ++++++++ .../storm_on_demand/requests/dns/get_zone.rb | 16 ++++++++ .../requests/dns/list_zones.rb | 16 ++++++++ .../requests/dns/update_zone.rb | 16 ++++++++ 11 files changed, 177 insertions(+), 2 deletions(-) create mode 100644 lib/fog/storm_on_demand/models/dns/zone.rb create mode 100644 lib/fog/storm_on_demand/models/dns/zones.rb create mode 100644 lib/fog/storm_on_demand/requests/dns/check_zone_delegation.rb create mode 100644 lib/fog/storm_on_demand/requests/dns/create_zone.rb create mode 100644 lib/fog/storm_on_demand/requests/dns/delete_zone.rb create mode 100644 lib/fog/storm_on_demand/requests/dns/get_zone.rb create mode 100644 lib/fog/storm_on_demand/requests/dns/list_zones.rb create mode 100644 lib/fog/storm_on_demand/requests/dns/update_zone.rb diff --git a/lib/fog/storm_on_demand/dns.rb b/lib/fog/storm_on_demand/dns.rb index eb9c1ec77..a72e24677 100644 --- a/lib/fog/storm_on_demand/dns.rb +++ b/lib/fog/storm_on_demand/dns.rb @@ -17,6 +17,8 @@ module Fog model :record collection :records model :reverse + model :zone + collection :zones request_path 'fog/storm_on_demand/requests/dns' request :list_domains @@ -33,6 +35,13 @@ module Fog request :delete_reverse request :update_reverse + + request :create_zone + request :check_zone_delegation + request :delete_zone + request :get_zone + request :list_zones + request :update_zone class Mock diff --git a/lib/fog/storm_on_demand/models/dns/domains.rb b/lib/fog/storm_on_demand/models/dns/domains.rb index 926df7c73..5d8500f07 100644 --- a/lib/fog/storm_on_demand/models/dns/domains.rb +++ b/lib/fog/storm_on_demand/models/dns/domains.rb @@ -1,5 +1,5 @@ require 'fog/core/collection' -require 'fog/storm_on_demand/models/dns' +require 'fog/storm_on_demand/models/dns/domain' module Fog module DNS diff --git a/lib/fog/storm_on_demand/models/dns/records.rb b/lib/fog/storm_on_demand/models/dns/records.rb index 82f2e1a98..297f02d32 100644 --- a/lib/fog/storm_on_demand/models/dns/records.rb +++ b/lib/fog/storm_on_demand/models/dns/records.rb @@ -1,5 +1,5 @@ require 'fog/core/collection' -require 'fog/storm_on_demand/models/dns' +require 'fog/storm_on_demand/models/dns/record' module Fog module DNS diff --git a/lib/fog/storm_on_demand/models/dns/zone.rb b/lib/fog/storm_on_demand/models/dns/zone.rb new file mode 100644 index 000000000..0177cc414 --- /dev/null +++ b/lib/fog/storm_on_demand/models/dns/zone.rb @@ -0,0 +1,40 @@ +require 'fog/core/model' + +module Fog + module DNS + class StormOnDemand + + class Zone < Fog::Model + identity :id + attribute :active + attribute :delegation_checked + attribute :delegation_status + attribute :master + attribute :name + attribute :notified_serial + attribute :region_support + attribute :type + + def initialize(attributes={}) + super + end + + def delegation + requires :identity + service.check_zone_delegation(:id => identity).body['delegation'] + end + + def destroy + requires :identity + service.delete_zone(:id => identity).body['deleted'] + end + + def update(options={}) + requires :identity + service.update_zone({:id => identity}.merge!(options)) + end + + end + end + end +end diff --git a/lib/fog/storm_on_demand/models/dns/zones.rb b/lib/fog/storm_on_demand/models/dns/zones.rb new file mode 100644 index 000000000..88aa8a58e --- /dev/null +++ b/lib/fog/storm_on_demand/models/dns/zones.rb @@ -0,0 +1,30 @@ +require 'fog/core/collection' +require 'fog/storm_on_demand/models/dns/zone' + +module Fog + module DNS + class StormOnDemand + + class Zones < Fog::Collection + model Fog::DNS::StormOnDemand::Zone + + def create(options) + zone = service.create_zone(options).body + new(zone) + end + + def get(zone_id) + zone = service.get_zone(:id => zone_id).body + new(zone) + end + + def all(options={}) + zones = service.list_zones(options).body['items'] + load(zones) + end + + end + + end + end +end diff --git a/lib/fog/storm_on_demand/requests/dns/check_zone_delegation.rb b/lib/fog/storm_on_demand/requests/dns/check_zone_delegation.rb new file mode 100644 index 000000000..a300df269 --- /dev/null +++ b/lib/fog/storm_on_demand/requests/dns/check_zone_delegation.rb @@ -0,0 +1,16 @@ +module Fog + module DNS + class StormOnDemand + class Real + + def check_zone_delegation(options={}) + request( + :path => '/Network/DNS/Zone/delegation', + :body => Fog::JSON.encode(:params => options) + ) + end + + end + end + end +end diff --git a/lib/fog/storm_on_demand/requests/dns/create_zone.rb b/lib/fog/storm_on_demand/requests/dns/create_zone.rb new file mode 100644 index 000000000..a1dfc0a1d --- /dev/null +++ b/lib/fog/storm_on_demand/requests/dns/create_zone.rb @@ -0,0 +1,16 @@ +module Fog + module DNS + class StormOnDemand + class Real + + def create_zone(options={}) + request( + :path => '/Network/DNS/Zone/create', + :body => Fog::JSON.encode(:params => options) + ) + end + + end + end + end +end diff --git a/lib/fog/storm_on_demand/requests/dns/delete_zone.rb b/lib/fog/storm_on_demand/requests/dns/delete_zone.rb new file mode 100644 index 000000000..0c5ee34b2 --- /dev/null +++ b/lib/fog/storm_on_demand/requests/dns/delete_zone.rb @@ -0,0 +1,16 @@ +module Fog + module DNS + class StormOnDemand + class Real + + def delete_zone(options={}) + request( + :path => '/Network/DNS/Zone/delete', + :body => Fog::JSON.encode(:params => options) + ) + end + + end + end + end +end diff --git a/lib/fog/storm_on_demand/requests/dns/get_zone.rb b/lib/fog/storm_on_demand/requests/dns/get_zone.rb new file mode 100644 index 000000000..01498c29d --- /dev/null +++ b/lib/fog/storm_on_demand/requests/dns/get_zone.rb @@ -0,0 +1,16 @@ +module Fog + module DNS + class StormOnDemand + class Real + + def get_zone(options={}) + request( + :path => '/Network/DNS/Zone/details', + :body => Fog::JSON.encode(:params => options) + ) + end + + end + end + end +end diff --git a/lib/fog/storm_on_demand/requests/dns/list_zones.rb b/lib/fog/storm_on_demand/requests/dns/list_zones.rb new file mode 100644 index 000000000..79c6bb5c8 --- /dev/null +++ b/lib/fog/storm_on_demand/requests/dns/list_zones.rb @@ -0,0 +1,16 @@ +module Fog + module DNS + class StormOnDemand + class Real + + def list_zones(options={}) + request( + :path => '/Network/DNS/Zone/list', + :body => Fog::JSON.encode(:params => options) + ) + end + + end + end + end +end diff --git a/lib/fog/storm_on_demand/requests/dns/update_zone.rb b/lib/fog/storm_on_demand/requests/dns/update_zone.rb new file mode 100644 index 000000000..338333c0e --- /dev/null +++ b/lib/fog/storm_on_demand/requests/dns/update_zone.rb @@ -0,0 +1,16 @@ +module Fog + module DNS + class StormOnDemand + class Real + + def update_zone(options={}) + request( + :path => '/Network/DNS/Zone/update', + :body => Fog::JSON.encode(:params => options) + ) + end + + end + end + end +end