globodns_client 0.2.6 → 0.2.7
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.
- checksums.yaml +4 -4
- data/lib/globodns_client/connection.rb +27 -2
- data/lib/globodns_client/exceptions.rb +16 -0
- data/lib/globodns_client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f872379ce3df565845c09932bbe99801ddd9160e
|
4
|
+
data.tar.gz: 045da94de7c377aa0ced89c888f0853496801a08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2018-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|