globodns_client 0.2.6 → 0.2.7

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: c19b8aa381e3e5e80fffa070ca50e077449d53f8
4
- data.tar.gz: bf5db99934195821f1aa9273aa2424f7f9f368fe
3
+ metadata.gz: f872379ce3df565845c09932bbe99801ddd9160e
4
+ data.tar.gz: 045da94de7c377aa0ced89c888f0853496801a08
5
5
  SHA512:
6
- metadata.gz: 843ebd4316c6212f30e929d4425c2d9c72db26ef961f06bf56252748c129f27a52aee50e679ccf77685a377813db4f609c5fdc1a6f9969d0585a0fd0de144884
7
- data.tar.gz: 4eb2200f9b2d3a3548e71162f72751b9bf086e82b9b9612d2078c3e7948fcb76b2e25bea516b8bb962e817ca3474cd88ae0918772227776febabb21d1c685eec
6
+ metadata.gz: 08200e6ebc08ca659b612375566ed1fb0dc7b0b8ac6a4f2d5ae0312ee165e6553ee71defef904d53d76e0826d28b6bb9cafe16e1bfa78aec7748bdf848634b0d
7
+ data.tar.gz: 27447dce6d30bc7b4e0c7ebd9ace08e6dc199f5bdedc07cd347aac887b57237ab3912cf152eb5e7778ef4e3a71e23c79104d1afda99178cb84d9fb78fc5c5308
@@ -74,6 +74,19 @@ module GlobodnsClient
74
74
  res.empty? ? false : res
75
75
  end
76
76
 
77
+ def get_record_matching(key, kind, zone, content=[])
78
+ matching = []
79
+ records = get_record(key, kind, zone)
80
+
81
+ return false unless records
82
+
83
+ records.each do |record|
84
+ matching << record if content.include? record[:content]
85
+ end
86
+
87
+ matching.empty? ? false : matching
88
+ end
89
+
77
90
  def new_record(key, kind, value)
78
91
  zone = get_domain key
79
92
  unless zone.nil?
@@ -96,11 +109,23 @@ module GlobodnsClient
96
109
  response['record']
97
110
  end
98
111
 
99
- def delete_record(key, kind)
112
+ def delete_record(key, kind, content = [], remove_all = true)
113
+ if !remove_all and content.empty?
114
+ raise GlobodnsClient::MissingContent, "Record not found for (#{key}) with content (#{content})"
115
+ end
116
+
100
117
  zone = get_zone(key, kind)
101
- unless records = get_record(key, kind, zone)
118
+
119
+ if remove_all and content.empty?
120
+ records = get_record(key, kind, zone)
121
+ else
122
+ records = get_record_matching(key, kind, zone, content)
123
+ end
124
+
125
+ unless records
102
126
  raise GlobodnsClient::NotFound, "Record not found for (#{key})"
103
127
  end
128
+
104
129
  response=[]
105
130
  records.each do |record|
106
131
  response << request('delete', 'record', nil, record[:id])
@@ -30,4 +30,20 @@ module GlobodnsClient
30
30
  "#<#{self.class}: message: #{@message.inspect}>"
31
31
  end
32
32
  end
33
+
34
+ class MissingContent < StandardError
35
+ attr_reader :message
36
+
37
+ def initialize(message)
38
+ @message = message
39
+ end
40
+
41
+ def to_s #:nodoc:
42
+ "#{@message}"
43
+ end
44
+
45
+ def inspect #:nodoc:
46
+ "#<#{self.class}: message: #{@message.inspect}>"
47
+ end
48
+ end
33
49
  end
@@ -1,3 +1,3 @@
1
1
  module GlobodnsClient
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: globodns_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ernesto Thorp
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-13 00:00:00.000000000 Z
11
+ date: 2018-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client