record_store 7.1.1 → 8.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/record_store/provider/cloudflare/client.rb +4 -3
- data/lib/record_store/provider/cloudflare/response.rb +8 -0
- data/lib/record_store/provider/cloudflare.rb +38 -8
- data/lib/record_store/version.rb +1 -1
- data/template/secrets.json +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7680653d3944e3a5c8de1a31055e38266a379d4caed36f7eb30bb5ae27217d71
|
4
|
+
data.tar.gz: 5487a8cbcd8079815fbe3e0276e99360a16d954b02b6ed819639bd73e016bc5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ba282fe4046bf7169648d3eecb0137fefd8882dc4c7dbf3c5af0f17cf0ef56ba948d0235668057656c53c709f9372ee155e6aa3aab211c265fdc322e1d9c4ba
|
7
|
+
data.tar.gz: f4e9646af425cdbe7a6827f0fd88e8c24717c6ea21921228ab72164a7e1b019071533f2576ba25b77bf02e3477a22e2d00d0a4df0d1cbfb985e6137c562dd1f1
|
data/CHANGELOG.md
CHANGED
@@ -3,8 +3,9 @@ require_relative 'response'
|
|
3
3
|
|
4
4
|
module Cloudflare
|
5
5
|
class Client
|
6
|
-
|
7
|
-
|
6
|
+
API_FQDN = 'api.cloudflare.com'.freeze
|
7
|
+
|
8
|
+
def initialize(api_token)
|
8
9
|
@api_token = api_token
|
9
10
|
end
|
10
11
|
|
@@ -88,7 +89,7 @@ module Cloudflare
|
|
88
89
|
|
89
90
|
def build_uri(endpoint, params = {})
|
90
91
|
URI::HTTPS.build(
|
91
|
-
host:
|
92
|
+
host: API_FQDN,
|
92
93
|
path: endpoint.chomp('/'),
|
93
94
|
query: URI.encode_www_form(params),
|
94
95
|
)
|
@@ -27,6 +27,14 @@ module Cloudflare
|
|
27
27
|
result
|
28
28
|
end
|
29
29
|
|
30
|
+
def result_info_raw
|
31
|
+
result_info_raw = json['result_info']
|
32
|
+
|
33
|
+
return if result_info_raw.nil? || result_info_raw.empty? || !success
|
34
|
+
|
35
|
+
result_info_raw
|
36
|
+
end
|
37
|
+
|
30
38
|
def success
|
31
39
|
json['success']
|
32
40
|
end
|
@@ -20,20 +20,50 @@ module RecordStore
|
|
20
20
|
def retrieve_current_records(zone:, stdout: $stdout)
|
21
21
|
zone_id = zone_name_to_id(zone)
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
all_records = []
|
24
|
+
page = 1
|
25
|
+
per_page = 1000
|
26
|
+
|
27
|
+
loop do
|
28
|
+
response = nil
|
29
|
+
retry_on_connection_errors do
|
30
|
+
response = client.get("/client/v4/zones/#{zone_id}/dns_records", page: page, per_page: per_page)
|
31
|
+
end
|
32
|
+
|
33
|
+
records = response.result_raw || []
|
34
|
+
all_records.concat(records)
|
35
|
+
|
36
|
+
break if page * per_page >= response.result_info_raw['total_count']
|
37
|
+
|
38
|
+
page += 1
|
26
39
|
end
|
40
|
+
|
41
|
+
all_records.map { |api_body| build_from_api(api_body) }
|
27
42
|
end
|
28
43
|
|
29
44
|
# Returns an array of the zones managed by provider as strings
|
30
45
|
# Cloudflare returns zones across all accounts accessible by the API token
|
31
46
|
# Can implement filtering in request if needed
|
32
47
|
def zones
|
33
|
-
|
34
|
-
|
35
|
-
|
48
|
+
all_zones = []
|
49
|
+
page = 1
|
50
|
+
per_page = 50
|
51
|
+
|
52
|
+
loop do
|
53
|
+
response = nil
|
54
|
+
retry_on_connection_errors do
|
55
|
+
response = client.get('/client/v4/zones', page: page, per_page: per_page)
|
56
|
+
end
|
57
|
+
|
58
|
+
zones = response.result_raw || []
|
59
|
+
all_zones.concat(zones)
|
60
|
+
|
61
|
+
break if page * per_page >= response.result_info_raw['total_count']
|
62
|
+
|
63
|
+
page += 1
|
36
64
|
end
|
65
|
+
|
66
|
+
all_zones.map { |zone| zone['name'] }
|
37
67
|
end
|
38
68
|
|
39
69
|
def apply_changeset(changeset, stdout = $stdout)
|
@@ -167,14 +197,14 @@ module RecordStore
|
|
167
197
|
|
168
198
|
def client
|
169
199
|
Cloudflare::Client.new(
|
170
|
-
secrets['api_fqdn'],
|
171
200
|
secrets['api_token'],
|
172
201
|
)
|
173
202
|
end
|
174
203
|
|
175
204
|
def zone_name_to_id(zone_name)
|
176
205
|
retry_on_connection_errors do
|
177
|
-
|
206
|
+
params = { name: zone_name }
|
207
|
+
matching_zones = client.get("/client/v4/zones", params).result_raw
|
178
208
|
|
179
209
|
case matching_zones.size
|
180
210
|
when 0
|
data/lib/record_store/version.rb
CHANGED
data/template/secrets.json
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: record_store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 8.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Willem van Bergen
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-10-
|
12
|
+
date: 2024-10-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|