From 74cdb74beb01669d6eaff876a070d472c370112a Mon Sep 17 00:00:00 2001 From: Chris Luo Date: Fri, 13 Mar 2015 13:18:23 -0400 Subject: [PATCH] Clean up REST docs --- .gitignore | 1 + .idea/workspace.xml | 407 +++++++++++++----- CONTRIBUTORS.md | 1 + Rakefile | 9 + lib/fog/powerdns/models/dns/record.rb | 6 +- lib/fog/powerdns/models/dns/zone.rb | 1 - lib/fog/powerdns/requests/dns/delete_zone.rb | 2 +- .../powerdns/requests/dns/list_cryptokeys.rb | 3 +- lib/fog/powerdns/requests/dns/list_zones.rb | 2 +- lib/fog/powerdns/requests/dns/notify_zone.rb | 26 +- .../powerdns/requests/dns/retrieve_zone.rb | 26 +- .../powerdns/requests/dns/update_rrsets.rb | 26 +- lib/fog/powerdns/requests/dns/update_zone.rb | 4 +- 13 files changed, 385 insertions(+), 129 deletions(-) create mode 100644 CONTRIBUTORS.md diff --git a/.gitignore b/.gitignore index 0cb6eeb..c424c36 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ /pkg/ /spec/reports/ /tmp/ +/.idea/ \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 59d0704..41473ce 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,43 +2,19 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + @@ -62,16 +38,79 @@ - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -90,12 +129,6 @@ @@ -142,10 +187,10 @@ true - @@ -188,46 +233,6 @@ - + - + - + - + - + @@ -442,13 +447,6 @@ - - - - - - - @@ -456,14 +454,6 @@ - - - - - - - - @@ -515,13 +505,208 @@ + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md new file mode 100644 index 0000000..d9497b8 --- /dev/null +++ b/CONTRIBUTORS.md @@ -0,0 +1 @@ +* Chris Luo \ No newline at end of file diff --git a/Rakefile b/Rakefile index 809eb56..a0472f3 100644 --- a/Rakefile +++ b/Rakefile @@ -1,2 +1,11 @@ require "bundler/gem_tasks" +def name + @name ||= Dir['*.gemspec'].first.split('.').first +end + +desc "Open an irb session preloaded with this library" +task :console do + puts "#{name}" + sh "irb -rubygems -r ./lib/fog/powerdns.rb" +end \ No newline at end of file diff --git a/lib/fog/powerdns/models/dns/record.rb b/lib/fog/powerdns/models/dns/record.rb index 2bca51f..e792640 100644 --- a/lib/fog/powerdns/models/dns/record.rb +++ b/lib/fog/powerdns/models/dns/record.rb @@ -4,6 +4,7 @@ module Fog module DNS class PowerDNS class Record < Fog::Model + # TODO: Needs work to comply with powerdns api identity :name attribute :content @@ -20,12 +21,9 @@ def domain end def destroy # service.delete_record(id) - # maybe hack our own delete? this does nothing for now + # TODO: maybe hack our own delete? this does nothing for now true end - def zone - @zone - end end end diff --git a/lib/fog/powerdns/models/dns/zone.rb b/lib/fog/powerdns/models/dns/zone.rb index 8dc1898..7f99fe4 100644 --- a/lib/fog/powerdns/models/dns/zone.rb +++ b/lib/fog/powerdns/models/dns/zone.rb @@ -29,7 +29,6 @@ def records def save requires :zone - # TODO: What does this do? data = service.create_zone(zone).body["zone"] merge_attributes(data) true diff --git a/lib/fog/powerdns/requests/dns/delete_zone.rb b/lib/fog/powerdns/requests/dns/delete_zone.rb index c5a997a..d101112 100644 --- a/lib/fog/powerdns/requests/dns/delete_zone.rb +++ b/lib/fog/powerdns/requests/dns/delete_zone.rb @@ -14,7 +14,7 @@ class Real # * response<~Excon::Response>: # * body<~Hash>: # * status<~Integer> - 204 when successful - # TODO: Verify this returns + # def delete_zone(server, zone) request( diff --git a/lib/fog/powerdns/requests/dns/list_cryptokeys.rb b/lib/fog/powerdns/requests/dns/list_cryptokeys.rb index c9f746f..ea68b18 100644 --- a/lib/fog/powerdns/requests/dns/list_cryptokeys.rb +++ b/lib/fog/powerdns/requests/dns/list_cryptokeys.rb @@ -5,7 +5,8 @@ class Real # Get details of all public cryptokeys # # ==== Parameters - # Need server_id, zone_id + # server<~String> - server id + # zone<~String> - zone id # # ==== Returns # * response<~Excon::Response>: diff --git a/lib/fog/powerdns/requests/dns/list_zones.rb b/lib/fog/powerdns/requests/dns/list_zones.rb index 6a883ed..04a6d90 100644 --- a/lib/fog/powerdns/requests/dns/list_zones.rb +++ b/lib/fog/powerdns/requests/dns/list_zones.rb @@ -5,7 +5,7 @@ class Real # Get details of a server's DNS zones # # ==== Parameters - # * zone<~String> - server id + # * server<~String> - server id # # ==== Returns # * response<~Excon::Response>: diff --git a/lib/fog/powerdns/requests/dns/notify_zone.rb b/lib/fog/powerdns/requests/dns/notify_zone.rb index 1f8d070..80abf9d 100644 --- a/lib/fog/powerdns/requests/dns/notify_zone.rb +++ b/lib/fog/powerdns/requests/dns/notify_zone.rb @@ -11,8 +11,30 @@ class Real # * zone<~String> - zone name # # ==== Returns - # TODO: Fill this out - # + # TODO: Untested + # * response<~Excon::Response>: + # * body<~Hash>: + # * 'id': <~String>, + # * "name": <~String>, + # * 'type': <~String>, + # * 'url': <~String>, + # * 'kind': <~String>, + # * 'serial': <~Integer>, + # * 'notified_serial': <~Int>, + # * 'masters': <~Array, + # * 'dnssec': <~Boolean>, + # * 'nsec3param': <~String>, + # * 'nsec3narrow': <~Boolean>, + # * 'presigned': <~Boolean>, + # * 'soa_edit': '<~String>', + # * 'soa_edit_api': '<~String>', + # * 'account': '<~String>', + # * 'nameservers': <~Array>, + # * 'servers': <~Array>, + # * 'recursion_desired': <~Boolean>, + # * 'records': <~Array>, + # * 'comments': <~Array>, + # * status<~Integer> 200 when successful def notify_zone(server, zone) request( diff --git a/lib/fog/powerdns/requests/dns/retrieve_zone.rb b/lib/fog/powerdns/requests/dns/retrieve_zone.rb index 925133c..7390220 100644 --- a/lib/fog/powerdns/requests/dns/retrieve_zone.rb +++ b/lib/fog/powerdns/requests/dns/retrieve_zone.rb @@ -11,8 +11,30 @@ class Real # * zone<~String> - zone name # # ==== Returns - # TODO: Fill this out - # + # TODO: Untested + # * response<~Excon::Response>: + # * body<~Hash>: + # * 'id': <~String>, + # * "name": <~String>, + # * 'type': <~String>, + # * 'url': <~String>, + # * 'kind': <~String>, + # * 'serial': <~Integer>, + # * 'notified_serial': <~Int>, + # * 'masters': <~Array, + # * 'dnssec': <~Boolean>, + # * 'nsec3param': <~String>, + # * 'nsec3narrow': <~Boolean>, + # * 'presigned': <~Boolean>, + # * 'soa_edit': '<~String>', + # * 'soa_edit_api': '<~String>', + # * 'account': '<~String>', + # * 'nameservers': <~Array>, + # * 'servers': <~Array>, + # * 'recursion_desired': <~Boolean>, + # * 'records': <~Array>, + # * 'comments': <~Array>, + # * status<~Integer> 201 when successful def retrieve_zone(server, zone) request( diff --git a/lib/fog/powerdns/requests/dns/update_rrsets.rb b/lib/fog/powerdns/requests/dns/update_rrsets.rb index b315da2..5a0bf87 100644 --- a/lib/fog/powerdns/requests/dns/update_rrsets.rb +++ b/lib/fog/powerdns/requests/dns/update_rrsets.rb @@ -5,15 +5,31 @@ class Real # Modify existing RRset's of a zone # # ==== Parameters - # TODO: Display response JSON keys + # server<~String> - server id + # zone<~String> - zone id + # options<~Hash> - see pdns api for rules # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: - # * 'zone'<~Hash> The representation of the rrsets. + # * 'rrsets'<~Hash> The representation of the rrsets: + # * 'name': <~String>, + # * 'type': <~String>, + # * 'changetype': <~String>, + # * 'records' <~Hash> domain records: + # * 'content': <~String>, + # * 'name': <~String>, + # * 'ttl': <~Integer>, + # * 'type': <~String>, + # * 'disabled': <~Boolean>, + # * 'set-ptr': <~Boolean> + # * 'comments' <~Hash> comments: + # * 'account': <~String>, + # * 'content': <~String>, + # * 'modfied_at': <~Integer> - def update_rrsets(server, id, options = {}) - # TODO: Have kind default to Native + + def update_rrsets(server, zone, options = {}) options.each { |option, value| body[option] = value; } @@ -22,7 +38,7 @@ def update_rrsets(server, id, options = {}) :body => Fog::JSON.encode(body), :expects => 200, :method => 'PATCH', - :path => "/servers/#{server}/zones/#{id}/" + :path => "/servers/#{server}/zones/#{zone}/" ) end end diff --git a/lib/fog/powerdns/requests/dns/update_zone.rb b/lib/fog/powerdns/requests/dns/update_zone.rb index 15762c8..52b24f7 100644 --- a/lib/fog/powerdns/requests/dns/update_zone.rb +++ b/lib/fog/powerdns/requests/dns/update_zone.rb @@ -5,7 +5,9 @@ class Real # Modify a single zone in PowerDNS # # ==== Parameters - # server, name, options + # server<~String> - server id + # zone<~String> - zone id + # options<~Hash> - pairs enumerated below # # # ==== Returns