pdns_api 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa80cf3197ec8aadd0d2a93cf3cf0a1df581034c
4
- data.tar.gz: 5c0e8f49631af8097165db914a239cc527033992
3
+ metadata.gz: 657948fecf6bc98b2564c4ca8a662fe535effc76
4
+ data.tar.gz: 5f3d133e97e22df2ff682500d079bc0cbeed06f8
5
5
  SHA512:
6
- metadata.gz: 533c9908e0d64d37594c683476009952606007ed065f5ff06f4ced79199eb5bb1bf88f739ad487982f6d9adb6eaabbe30654bff5e7378492f94ea2ed15f4e5c6
7
- data.tar.gz: 52f239530706b483f0b21b55fc8c014a0e84c609ff0b51cd0dfda9403bc51d3b403123358c0ef858f62339a84edaa62b3eb6e993fd1ee7a1b026e2831e66e745
6
+ metadata.gz: b1f5e2794d3d8da64596717ac8beb59328e90eb6774e91561aff3183eb6ed9e5bfb74549056c6247599279b56482046dad74e195692d4d2d11b13a20131978bc
7
+ data.tar.gz: b4f3d1ac66fd8abe82170710da88927f86d4283018384804188eb715472203347306c227d8d2536a17df995af6286587e7dfbcd2545eb00551c85a37e72ec077
data/lib/pdns_api/api.rb CHANGED
@@ -44,6 +44,14 @@ module PDNS
44
44
  #
45
45
  # If +info+ is set this method updates the current information.
46
46
  # The current information is used to create the object.
47
+ #
48
+ # Example:
49
+ # zone.create(
50
+ # name: zone.id,
51
+ # kind: 'Native',
52
+ # dnssec: true,
53
+ # nameservers: %w( ns0.example.com. ns1.example.com. )
54
+ # )
47
55
  def create(info = nil)
48
56
  info(info)
49
57
  @http.post("#{@parent.url}/#{@class}", @info)
@@ -25,10 +25,6 @@ module PDNS
25
25
  # The name of the configuration option.
26
26
  attr_accessor :name
27
27
 
28
- ##
29
- # The value of the configuration option.
30
- attr_accessor :value
31
-
32
28
  ##
33
29
  # Disabled common methods
34
30
  undef_method :delete
@@ -75,6 +71,10 @@ module PDNS
75
71
  #
76
72
  # If +value+ is set, the current +value+ is used.
77
73
  # If +value+ is not set, +value+ is updated and then used.
74
+ #
75
+ # Example:
76
+ # config.change('PowerDNS v3.14159265')
77
+ #
78
78
  def change(value = nil)
79
79
  value(value)
80
80
  @http.put(@url, @info)
@@ -25,10 +25,6 @@ module PDNS
25
25
  # The kind of metadata.
26
26
  attr_accessor :kind
27
27
 
28
- ##
29
- # The value of the metadata.
30
- attr_accessor :value
31
-
32
28
  ##
33
29
  # Creates a configuration option object.
34
30
  #
@@ -20,5 +20,5 @@
20
20
  module PDNS
21
21
  ##
22
22
  # The version of +pdns_api+.
23
- VERSION = '0.1.1'.freeze
23
+ VERSION = '0.1.2'.freeze
24
24
  end
data/lib/pdns_api/zone.rb CHANGED
@@ -47,6 +47,13 @@ module PDNS
47
47
  ##
48
48
  # Modifies information (records) of a zone.
49
49
  # Also formats records to match the API requirements.
50
+ #
51
+ # Example:
52
+ # zone.modify([
53
+ # changetype: 'DELETE',
54
+ # name: 'www.example.com.',
55
+ # type: 'A'
56
+ # ])
50
57
  def modify(rrsets)
51
58
  rrsets.map! do |rrset|
52
59
  rrset = format_records(rrset) if rrset.key?(:records)
@@ -92,6 +99,30 @@ module PDNS
92
99
  # Adds records to the ones already existing in the zone.
93
100
  #
94
101
  # The existing records are retrieved and merged with the ones given in +rrsets+.
102
+ #
103
+ # Elements of +rrsets+ can contain +:records+, which can be:
104
+ # - A +String+ containing a single record value.
105
+ # - An +Array+ containing record values.
106
+ # - An +Array+ containing hashes as specified in the PowerDNS API.
107
+ #
108
+ # Example:
109
+ # zone.add({
110
+ # name: 'www0.example.com.',
111
+ # type: 'A',
112
+ # ttl: 86_400,
113
+ # records: '127.0.1.1',
114
+ # }, {
115
+ # name: 'www1.example.com.',
116
+ # type: 'A',
117
+ # ttl: 86_400,
118
+ # records: ['127.0.1.1', '127.0.0.1'],
119
+ # }, {
120
+ # name: 'www2.example.com.',
121
+ # type: 'A',
122
+ # ttl: 86_400,
123
+ # records: [{content: '127.0.1.1'},{content: '127.0.0.1', disabled: true}],
124
+ # })
125
+ #
95
126
  def add(*rrsets)
96
127
  # Get current zone data
97
128
  data = get
@@ -114,6 +145,32 @@ module PDNS
114
145
 
115
146
  ##
116
147
  # Updates (replaces) records for a name/type combination in the zone.
148
+ #
149
+ # +rrsets+ is used to create a changeset.
150
+ #
151
+ # Elements of +rrsets+ can contain +:records+, which can be:
152
+ # - A +String+ containing a single record value.
153
+ # - An +Array+ containing record values.
154
+ # - An +Array+ containing hashes as specified in the PowerDNS API.
155
+ #
156
+ # Example:
157
+ # zone.update({
158
+ # name: 'www0.example.com.',
159
+ # type: 'A',
160
+ # ttl: 86_400,
161
+ # records: '127.0.1.1'
162
+ # }, {
163
+ # name: 'www1.example.com.',
164
+ # type: 'A',
165
+ # ttl: 86_400,
166
+ # records: ['127.0.1.1', '127.0.0.1']
167
+ # }, {
168
+ # name: 'www2.example.com.',
169
+ # type: 'A',
170
+ # ttl: 86_400,
171
+ # records: [{content: '127.0.1.1'},{content: '127.0.0.1', disabled: true}]
172
+ # })
173
+ #
117
174
  def update(*rrsets)
118
175
  # Set type and format records
119
176
  rrsets.map! do |rrset|
@@ -126,6 +183,16 @@ module PDNS
126
183
 
127
184
  ##
128
185
  # Removes all records for a name/type combination from the zone.
186
+ #
187
+ # Example:
188
+ # zone.remove({
189
+ # name: 'www0.example.com.',
190
+ # type: 'A'
191
+ # }, {
192
+ # name: 'www1.example.com.',
193
+ # type: 'A'
194
+ # })
195
+ #
129
196
  def remove(*rrsets)
130
197
  # Set type and format records
131
198
  rrsets.map! do |rrset|
@@ -142,6 +209,17 @@ module PDNS
142
209
  #
143
210
  # If +kind+ is set a +Metadata+ object is returned using the provided +kind+.
144
211
  # If +value+ is set as well, a complete Metadata object is returned.
212
+ #
213
+ # Example:
214
+ # # Retrieve all metadata in a hash
215
+ # zone.metadata
216
+ # # Create a metadata object
217
+ # meta = zone.metadata('ALLOW-AXFR-FROM')
218
+ # puts meta.get
219
+ # # Create a metadata object with a value
220
+ # meta = zone.metadata('ALLOW-AXFR-FROM','AUTO-NS')
221
+ # meta.change
222
+ #
145
223
  def metadata(kind = nil, value = nil)
146
224
  return Metadata.new(@http, self, kind, value) unless kind.nil? || value.nil?
147
225
  return Metadata.new(@http, self, kind) unless kind.nil?
@@ -163,6 +241,10 @@ module PDNS
163
241
  # containing +CryptoKey+ objects.
164
242
  #
165
243
  # If +id+ is set a +CryptoKey+ object with the provided ID is returned.
244
+ #
245
+ # Example:
246
+ # ckeys = zone.cryptokeys
247
+ # ckey = zone.cryptokey(12)
166
248
  def cryptokeys(id = nil)
167
249
  return CryptoKey.new(@http, self, id) unless id.nil?
168
250
 
@@ -214,8 +296,8 @@ module PDNS
214
296
  # Returns the records matching the ones in +rrset+ from +data+.
215
297
  # +data+ should be the result from +get+.
216
298
  def current_records(rrset, data)
217
- # Get the records from the data, `records` is v0, `rrset` is v1
218
- records = data[:records] || data[:rrset]
299
+ # Get the records from the data, `records` is v0, `rrsets` is v1
300
+ records = data[:records] || data[:rrsets]
219
301
 
220
302
  # Select records matching type/name
221
303
  current = records.select { |r| r[:name] == rrset[:name] && r[:type] == rrset[:type] }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdns_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Silke Hofstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-30 00:00:00.000000000 Z
11
+ date: 2016-05-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A gem for manipulation of DNS through the PowerDNS API
14
14
  email: silke.ruby@slxh.nl