cloudflare_client_rb 4.1.0 → 4.2.0

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: 97207869fc9f1586e9c8f2d51b1e2467d615020c
4
- data.tar.gz: b3c6f6042a41012d3629f2e93364bbc34c0b4051
3
+ metadata.gz: 6caad8ab3e2fc3f8e7c5c7ab755403d6fbd59461
4
+ data.tar.gz: e0161d72bb3ed8aea7e7a060d9c9b4595c76e813
5
5
  SHA512:
6
- metadata.gz: 49a932c5de6eeb9601d598fe49acdef3d234c20c70cd22f24fab7a4807f8b653d1610be67372ff13c55bb59e0f7ab918ff11ab8cad39c056bef0da909bdd3e15
7
- data.tar.gz: e97e7da2f1201ed21693d4c87879d962dba9101fcdf16b1f70d518a592f493a9f76af60d82fd88b44966ac1544fb3de1dab5176427abf5451a665a70f3d86bc9
6
+ metadata.gz: 8b5cfcca92054684809d2f12a901dd599855ddadc7973f366d66424547e10da3acce604efd3b0aaa8c8f978b989a659bd70e765b0838cab8acaa5a51d64d080b
7
+ data.tar.gz: 0e4ace9d2131291d5c318da8dd34eb502af686e45b28be312cc91c9c8823064fbc858d675a82107f05e7d52d9503852c807b7fab938272d07e428a9ed1f9074c
@@ -1,3 +1,3 @@
1
1
  class CloudflareClient
2
- VERSION = '4.1.0'
2
+ VERSION = '4.2.0'
3
3
  end
@@ -9,9 +9,8 @@ class CloudflareClient::Zone::CustomHostname < CloudflareClient::Zone::Base
9
9
  # create custom_hostname
10
10
  # - :custom_metadata may only work for enterprise or better customers
11
11
  # - :ssl has undocumented properties: 'custom_certificate' and 'custom_key', or can be nulled
12
- def create(hostname:, ssl: DEFAULT_SSL_PROPERTIES, custom_metadata: {})
12
+ def create(hostname:, ssl: DEFAULT_SSL_PROPERTIES, custom_metadata: {}, custom_origin_server: nil)
13
13
  #FIXME: implement checks for the custom_metedata/find out of it's going to be exposed to anyone else
14
- #"custom_metadata":{"origin_override":"hostname.zendesk.com"}
15
14
  #"custom_metadata":{"hsts_enabled":"true"}
16
15
  #"custom_metadata":{"hsts_enabled":"true","custom_maxage":value}
17
16
  id_check('hostname', hostname)
@@ -22,6 +21,7 @@ class CloudflareClient::Zone::CustomHostname < CloudflareClient::Zone::Base
22
21
  end
23
22
 
24
23
  data = { hostname: hostname, ssl: ssl }
24
+ data[:custom_origin_server] = custom_origin_server unless custom_origin_server.nil?
25
25
  data[:custom_metadata] = custom_metadata unless custom_metadata.empty?
26
26
 
27
27
  cf_post(path: "/zones/#{zone_id}/custom_hostnames", data: data)
@@ -53,7 +53,7 @@ class CloudflareClient::Zone::CustomHostname < CloudflareClient::Zone::Base
53
53
  ##
54
54
  # update a custom hosntame
55
55
  # https://api.cloudflare.com/#custom-hostname-for-a-zone-update-custom-hostname-configuration
56
- def update(id:, ssl: {}, custom_metadata: nil)
56
+ def update(id:, ssl: {}, custom_metadata: nil, custom_origin_server: nil)
57
57
  id_check('id', id)
58
58
 
59
59
  data = {}
@@ -69,10 +69,13 @@ class CloudflareClient::Zone::CustomHostname < CloudflareClient::Zone::Base
69
69
 
70
70
  unless custom_metadata.nil?
71
71
  raise 'custom_metadata must be an object' unless custom_metadata.is_a?(Hash)
72
-
73
72
  data[:custom_metadata] = custom_metadata
74
73
  end
75
74
 
75
+ unless custom_origin_server.nil?
76
+ data[:custom_origin_server] = custom_origin_server
77
+ end
78
+
76
79
  cf_patch(path: "/zones/#{zone_id}/custom_hostnames/#{id}", data: data)
77
80
  end
78
81
 
@@ -153,7 +153,6 @@ class CloudflareClient
153
153
  request.url(API_BASE + path) unless path.nil?
154
154
  request.body = data.to_json
155
155
  end
156
- raise(JSON.parse(result.body).dig('errors').first.to_s) unless result.status == 200
157
156
  JSON.parse(result.body, symbolize_names: true)
158
157
  end
159
158
 
@@ -165,7 +164,6 @@ class CloudflareClient
165
164
  request.params = params if params.values.any? { |i| !i.nil? }
166
165
  end
167
166
  end
168
- raise(JSON.parse(result.body).dig('errors').first.to_s) unless result.status == 200
169
167
  unless raw.nil?
170
168
  return result.body
171
169
  end
@@ -182,17 +180,14 @@ class CloudflareClient
182
180
  request.url(API_BASE + path) unless path.nil?
183
181
  request.body = data.to_json unless data.nil?
184
182
  end
185
- raise(JSON.parse(result.body).dig('errors').first.to_s) unless result.status == 200
186
183
  JSON.parse(result.body, symbolize_names: true)
187
184
  end
188
185
 
189
186
  def cf_patch(path: nil, data: {})
190
- valid_response_codes = [200, 202]
191
187
  result = @cf_client.patch do |request|
192
188
  request.url(API_BASE + path) unless path.nil?
193
189
  request.body = data.to_json unless data.empty?
194
190
  end
195
- raise(JSON.parse(result.body).dig('errors').first.to_s) unless valid_response_codes.include?(result.status)
196
191
  JSON.parse(result.body, symbolize_names: true)
197
192
  end
198
193
 
@@ -201,7 +196,6 @@ class CloudflareClient
201
196
  request.url(API_BASE + path) unless path.nil?
202
197
  request.body = data.to_json unless data.empty?
203
198
  end
204
- raise(JSON.parse(result.body).dig('errors').first.to_s) unless result.status == 200
205
199
  JSON.parse(result.body, symbolize_names: true)
206
200
  end
207
201
 
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.1.0
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ian waters
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-13 00:00:00.000000000 Z
11
+ date: 2018-01-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: iwaters@zendesk.com