diff --git a/lib/fog/slicehost/compute.rb b/lib/fog/slicehost/compute.rb index 22d954859..88e62fa71 100644 --- a/lib/fog/slicehost/compute.rb +++ b/lib/fog/slicehost/compute.rb @@ -28,10 +28,10 @@ module Fog request :delete_zone request :get_zones request :get_zone - # request :create_record - # request :delete_record - # request :get_records - # request :get_record + request :create_record + request :delete_record + request :get_records + request :get_record class Mock diff --git a/lib/fog/slicehost/parsers/compute/create_record.rb b/lib/fog/slicehost/parsers/compute/create_record.rb new file mode 100644 index 000000000..5b487e777 --- /dev/null +++ b/lib/fog/slicehost/parsers/compute/create_record.rb @@ -0,0 +1,26 @@ +module Fog + module Parsers + module Slicehost + module Compute + + class CreateRecord < Fog::Parsers::Base + + def reset + @response = {} + end + + def end_element(name) + case name + when 'zone-id', 'ttl', 'id' + @response[name] = @value.to_i + when 'record-type', 'name', 'data', 'active', 'aux' + @response[name] = @value + end + end + + end + + end + end + end +end diff --git a/lib/fog/slicehost/parsers/compute/get_record.rb b/lib/fog/slicehost/parsers/compute/get_record.rb new file mode 100644 index 000000000..6a42be59a --- /dev/null +++ b/lib/fog/slicehost/parsers/compute/get_record.rb @@ -0,0 +1,25 @@ +module Fog + module Parsers + module Slicehost + module Compute + + class GetRecord < Fog::Parsers::Base + + def reset + @response = { } + end + + def end_element(name) + case name + when 'zone-id', 'ttl' + @response[name] = @value.to_i + when 'record-type', 'name', 'data', 'active', 'aux' + @response[name] = @value + end + + end + + end + end + end +end diff --git a/lib/fog/slicehost/parsers/compute/get_records.rb b/lib/fog/slicehost/parsers/compute/get_records.rb new file mode 100644 index 000000000..b7822bcdc --- /dev/null +++ b/lib/fog/slicehost/parsers/compute/get_records.rb @@ -0,0 +1,30 @@ +module Fog + module Parsers + module Slicehost + module Compute + + class GetRecords < Fog::Parsers::Base + + def reset + @record = {} + @response = { 'records' => [] } + end + + def end_element(name) + case name + when 'zone-id', 'ttl' + @record[name] = @value.to_i + when 'record-type', 'name', 'data', 'active', 'aux' + @record[name] = @value + when 'record' + @response['records'] << @record + @record = {} + end + end + + end + + end + end + end +end diff --git a/lib/fog/slicehost/requests/compute/create_record.rb b/lib/fog/slicehost/requests/compute/create_record.rb new file mode 100644 index 000000000..3bace6425 --- /dev/null +++ b/lib/fog/slicehost/requests/compute/create_record.rb @@ -0,0 +1,42 @@ +module Fog + module Slicehost + class Compute + class Real + + require 'fog/slicehost/parsers/compute/create_record' + + # Create a new record in a DNS zone + # ==== Parameters + # * record_type<~String> - type of DNS record to create (A, CNAME, etc) + # * zone_id<~Integer> - ID of the zone record should be a part of + # * name<~String> - DNS name record should be for (ie for an A record, the host name) + # * data<~String> - data for the DNS record (ie for an A record, the IP address) + # + # ==== Returns + # * response<~Excon::Response>: + # * 'name'<~String> - domain added + # * 'id'<~Integer> - Id of zone/domain + # * 'ttl'<~Integer> - TimeToLive for zone (how long client can cache) + # * 'active'<~String> - whether zone is active or disabled + def create_record( record_type, zone_id, name, data) + request( + :body => %Q{#{record_type}#{zone_id}#{name}#{data}}, + :expects => 201, + :method => 'POST', + :parser => Fog::Parsers::Slicehost::Compute::CreateRecord.new, + :path => 'records.xml' + ) + end + + end + + class Mock + + def create_record( record_type, zone_id, name, data) + Fog::Mock.not_implemented + end + + end + end + end +end diff --git a/lib/fog/slicehost/requests/compute/delete_record.rb b/lib/fog/slicehost/requests/compute/delete_record.rb new file mode 100644 index 000000000..e46003546 --- /dev/null +++ b/lib/fog/slicehost/requests/compute/delete_record.rb @@ -0,0 +1,31 @@ +module Fog + module Slicehost + class Compute + class Real + + # Delete a record from DNS zone + # ==== Parameters + # * record_id<~Integer> - Id of DNS record to delete + # + # ==== Returns + # * response<~Excon::Response>: + def delete_record(record_id) + request( + :expects => 200, + :method => 'DELETE', + :path => "records/#{record_id}.xml" + ) + end + + end + + class Mock + + def delete_record(record_id) + Fog::Mock.not_implemented + end + + end + end + end +end diff --git a/lib/fog/slicehost/requests/compute/delete_zone.rb b/lib/fog/slicehost/requests/compute/delete_zone.rb index 891590a20..e127733a4 100644 --- a/lib/fog/slicehost/requests/compute/delete_zone.rb +++ b/lib/fog/slicehost/requests/compute/delete_zone.rb @@ -10,17 +10,6 @@ module Fog # ==== Returns # * response<~Excon::Response>: # * body<~Array>: - # * 'addresses'<~Array> - Ip addresses for the slice - # * 'backup-id'<~Integer> - Id of backup slice was booted from - # * 'bw-in'<~Integer> - Incoming bandwidth total for current billing cycle, in Gigabytes - # * 'bw-out'<~Integer> - Outgoing bandwidth total for current billing cycle, in Gigabytes - # * 'flavor-id'<~Integer> - Id of flavor slice was booted from - # * 'id'<~Integer> - Id of the slice - # * 'image-id'<~Integer> - Id of image slice was booted from - # * 'name'<~String> - Name of the slice - # * 'progress'<~Integer> - Progress of current action, in percentage - # * 'root-password'<~String> - Root password of slice - # * 'status'<~String> - Current status of the slice def delete_zone(zone_id) request( :expects => 200, diff --git a/lib/fog/slicehost/requests/compute/get_record.rb b/lib/fog/slicehost/requests/compute/get_record.rb new file mode 100644 index 000000000..d1d3a7b24 --- /dev/null +++ b/lib/fog/slicehost/requests/compute/get_record.rb @@ -0,0 +1,41 @@ +module Fog + module Slicehost + class Compute + class Real + + require 'fog/slicehost/parsers/compute/get_record' + + # Get all the DNS records across all the DNS zones for this account + # + # ==== Returns + # * response<~Excon::Response>: + # * body<~Array>: + # * 'addresses'<~Array> - Ip addresses for the slice + # * 'backup-id'<~Integer> - Id of backup slice was booted from + # * 'flavor_id'<~Integer> - Id of flavor slice was booted from + # * 'id'<~Integer> - Id of the slice + # * 'image-id'<~Integer> - Id of image slice was booted from + # * 'name'<~String> - Name of the slice + # * 'progress'<~Integer> - Progress of current action, in percentage + # * 'status'<~String> - Current status of the slice + def get_record( record_id) + request( + :expects => 200, + :method => 'GET', + :parser => Fog::Parsers::Slicehost::Compute::GetRecords.new, + :path => "records/#{record_id}.xml" + ) + end + + end + + class Mock + + def get_record(record_id) + Fog::Mock.not_implemented + end + + end + end + end +end diff --git a/lib/fog/slicehost/requests/compute/get_records.rb b/lib/fog/slicehost/requests/compute/get_records.rb index 5b495df73..e4842d7fe 100644 --- a/lib/fog/slicehost/requests/compute/get_records.rb +++ b/lib/fog/slicehost/requests/compute/get_records.rb @@ -5,15 +5,13 @@ module Fog require 'fog/slicehost/parsers/compute/get_records' - # Get list of DNS zones + # Get all the DNS records across all the DNS zones for this account # # ==== Returns # * response<~Excon::Response>: # * body<~Array>: # * 'addresses'<~Array> - Ip addresses for the slice # * 'backup-id'<~Integer> - Id of backup slice was booted from - # * 'bw-in'<~Float> - Incoming bandwidth total for current billing cycle, in Gigabytes - # * 'bw-out'<~Float> - Outgoing bandwidth total for current billing cycle, in Gigabytes # * 'flavor_id'<~Integer> - Id of flavor slice was booted from # * 'id'<~Integer> - Id of the slice # * 'image-id'<~Integer> - Id of image slice was booted from @@ -25,7 +23,7 @@ module Fog :expects => 200, :method => 'GET', :parser => Fog::Parsers::Slicehost::Compute::GetRecords.new, - :path => 'records.xml' + :path => "records.xml" ) end diff --git a/lib/fog/slicehost/requests/compute/get_zones.rb b/lib/fog/slicehost/requests/compute/get_zones.rb index 1a95ea16b..ed27e4f28 100644 --- a/lib/fog/slicehost/requests/compute/get_zones.rb +++ b/lib/fog/slicehost/requests/compute/get_zones.rb @@ -12,8 +12,6 @@ module Fog # * body<~Array>: # * 'addresses'<~Array> - Ip addresses for the slice # * 'backup-id'<~Integer> - Id of backup slice was booted from - # * 'bw-in'<~Float> - Incoming bandwidth total for current billing cycle, in Gigabytes - # * 'bw-out'<~Float> - Outgoing bandwidth total for current billing cycle, in Gigabytes # * 'flavor_id'<~Integer> - Id of flavor slice was booted from # * 'id'<~Integer> - Id of the slice # * 'image-id'<~Integer> - Id of image slice was booted from