cloudflare_client_rb 4.2.3 → 4.2.10
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 125802fef0c3221bb92cde156cafd90ded68d591
|
4
|
+
data.tar.gz: 627757654b8419bab16194820c5bbc5e4b8d7ba9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60eeece7b3ecd4d5b975415017aac7035c587422bae15fd1cef05a2e217885737dec81645bd221c3c0c4bdeb26f66c0b49798f7ac8a5f4a29a6e1e71800b2178
|
7
|
+
data.tar.gz: 1578ee65e475099591342d754ff59f1abb7ea2bb00b56c96b2383fc28aaf3a51fa6957644933e2b770d8f3836ba0b414976a9309a1a07af91adc4c8ed46fb15d
|
data/lib/cloudflare_client.rb
CHANGED
@@ -51,10 +51,10 @@ class CloudflareClient
|
|
51
51
|
websockets
|
52
52
|
].freeze
|
53
53
|
|
54
|
-
def initialize(auth_key: nil, email: nil)
|
55
|
-
raise('Missing auth_key') if auth_key.nil?
|
56
|
-
raise('missing email') if email.nil?
|
57
|
-
@cf_client ||= build_client(auth_key: auth_key, email: email)
|
54
|
+
def initialize(auth_key: nil, email: nil, auth_token: nil, &block)
|
55
|
+
raise('Missing auth_key or auth_token') if auth_key.nil? && auth_token.nil?
|
56
|
+
raise('missing email') if email.nil? && !auth_key.nil?
|
57
|
+
@cf_client ||= build_client(auth_key: auth_key, email: email, auth_token: auth_token, &block)
|
58
58
|
end
|
59
59
|
|
60
60
|
#TODO: add the time based stuff
|
@@ -131,19 +131,24 @@ class CloudflareClient
|
|
131
131
|
end
|
132
132
|
|
133
133
|
def build_client(params)
|
134
|
-
raise('Missing auth_key') if params[:auth_key].nil?
|
135
|
-
raise('Missing auth email') if params[:email].nil?
|
136
134
|
# we need multipart form encoding for some of these operations
|
137
135
|
client = Faraday.new(url: API_BASE) do |conn|
|
138
136
|
conn.request :multipart
|
139
137
|
conn.request :url_encoded
|
140
138
|
conn.use Middleware::Response::RaiseError
|
141
|
-
conn.adapter :net_http
|
142
139
|
end
|
143
|
-
|
144
|
-
client.headers['X-Auth-User-Service-Key '] = params[:auth_key] #FIXME, is this always the same?
|
145
|
-
client.headers['X-Auth-Email'] = params[:email]
|
140
|
+
|
146
141
|
client.headers['Content-Type'] = 'application/json'
|
142
|
+
if params[:auth_token]
|
143
|
+
client.headers['Authorization'] = "Bearer #{params[:auth_token]}"
|
144
|
+
else
|
145
|
+
client.headers['X-Auth-Key'] = params[:auth_key]
|
146
|
+
client.headers['X-Auth-User-Service-Key '] = params[:auth_key] #FIXME, is this always the same?
|
147
|
+
client.headers['X-Auth-Email'] = params[:email]
|
148
|
+
end
|
149
|
+
|
150
|
+
yield client if block_given?
|
151
|
+
client.adapter :net_http
|
147
152
|
client
|
148
153
|
end
|
149
154
|
|
@@ -204,4 +209,4 @@ class CloudflareClient
|
|
204
209
|
return false unless POSSIBLE_API_SETTINGS.include?(name)
|
205
210
|
true
|
206
211
|
end
|
207
|
-
end
|
212
|
+
end
|
@@ -4,7 +4,7 @@ class CloudflareClient
|
|
4
4
|
attr_reader :response, :method, :uri, :url
|
5
5
|
|
6
6
|
def initialize(message = nil, response = nil, method = nil, uri = nil, url = nil)
|
7
|
-
super("#{message}, #{method}
|
7
|
+
super("#{message}, #{method&.upcase} #{url} #{response&.body}")
|
8
8
|
@response = response
|
9
9
|
@method = method
|
10
10
|
@uri = uri
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudflare_client_rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.
|
4
|
+
version: 4.2.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ian waters
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: iwaters@zendesk.com
|
@@ -52,7 +52,7 @@ files:
|
|
52
52
|
- lib/cloudflare_client/zone/subscription.rb
|
53
53
|
homepage: https://github.com/zendesk/cloudflare_client_rb
|
54
54
|
licenses:
|
55
|
-
- Apache
|
55
|
+
- Apache-2.0
|
56
56
|
metadata: {}
|
57
57
|
post_install_message:
|
58
58
|
rdoc_options: []
|