zerigo_dns 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/example/sample.rb +8 -8
- data/lib/activeresource-ext.rb +1 -1
- metadata +1 -1
data/example/sample.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
# First, require the Zerigo DNS library for ActiveResource.
|
5
5
|
|
6
|
-
require '
|
6
|
+
require 'zerigo_dns'
|
7
7
|
|
8
8
|
# All API request require a Zerigo account and an Account API key. We'll set
|
9
9
|
# them here for later reference. The 'user' is your regular login email.
|
@@ -28,7 +28,7 @@ Zerigo::NS::Base.password = 'api_token'
|
|
28
28
|
# eg: zone.default_ttl, not zone.default-ttl
|
29
29
|
|
30
30
|
puts '', "Retrieving list of first 20 zones..."
|
31
|
-
zones = Zerigo::
|
31
|
+
zones = Zerigo::DNS::Zone.find(:all, :params=>{:per_page=>20, :page=>1})
|
32
32
|
|
33
33
|
# Now print a list of those zones
|
34
34
|
zones.each do |zone|
|
@@ -49,7 +49,7 @@ end
|
|
49
49
|
zone = zones.first
|
50
50
|
puts '', "Hosts for zone #{zone.domain} (id: #{zone.id})"
|
51
51
|
|
52
|
-
hosts = Zerigo::
|
52
|
+
hosts = Zerigo::DNS::Host.find(:all, :params=>{:zone_id=>zone.id, :per_page=>20, :page=>1})
|
53
53
|
hosts.each do |host|
|
54
54
|
puts " #{host.hostname} (id: #{host.id})"
|
55
55
|
end
|
@@ -62,7 +62,7 @@ end
|
|
62
62
|
# the last request.
|
63
63
|
|
64
64
|
puts '', "Loading a single zone..."
|
65
|
-
zone = Zerigo::
|
65
|
+
zone = Zerigo::DNS::Zone.find(zones.first.id)
|
66
66
|
|
67
67
|
puts " Loaded zone #{zone.id} (#{zone.domain})"
|
68
68
|
|
@@ -71,7 +71,7 @@ puts " Loaded zone #{zone.id} (#{zone.domain})"
|
|
71
71
|
|
72
72
|
puts '', "Loading a non-existent zone..."
|
73
73
|
begin
|
74
|
-
zone2 = Zerigo::
|
74
|
+
zone2 = Zerigo::DNS::Zone.find(987654321)
|
75
75
|
puts " Loaded zone #{zone2.id} (#{zone2.domain})"
|
76
76
|
rescue ActiveResource::ResourceNotFound
|
77
77
|
puts " Zone not found"
|
@@ -85,7 +85,7 @@ puts '', "Creating a random zone that is invalid..."
|
|
85
85
|
now = Time.now.to_i
|
86
86
|
vals = {:domain=>"example-#{now}.org", :ns_type=>'not_valid' }
|
87
87
|
|
88
|
-
newzone = Zerigo::
|
88
|
+
newzone = Zerigo::DNS::Zone.create(vals)
|
89
89
|
if newzone.errors.empty?
|
90
90
|
puts " Zone #{newzone.domain} created successfully with id #{newzone.id}."
|
91
91
|
else
|
@@ -99,7 +99,7 @@ puts '', "Fixing and resubmitting that random zone..."
|
|
99
99
|
|
100
100
|
vals[:ns_type] = 'pri_sec' # options for this are 'pri_sec' (the default and most common), 'pri', and 'sec' -- see the API docs for details
|
101
101
|
|
102
|
-
newzone = Zerigo::
|
102
|
+
newzone = Zerigo::DNS::Zone.create(vals)
|
103
103
|
if newzone.errors.empty?
|
104
104
|
puts " Zone #{newzone.domain} created successfully with id #{newzone.id}."
|
105
105
|
else
|
@@ -135,7 +135,7 @@ vals2 = {:hostname=>'www',
|
|
135
135
|
|
136
136
|
# A host has to be assigned to a zone. This is done by including 'zone_id'
|
137
137
|
# in the vals2 hash.
|
138
|
-
newhost = Zerigo::
|
138
|
+
newhost = Zerigo::DNS::Host.create(vals2)
|
139
139
|
if newhost.errors.empty?
|
140
140
|
puts " Host #{newhost.hostname} created successfully with id #{newhost.id}."
|
141
141
|
else
|
data/lib/activeresource-ext.rb
CHANGED