cloudflare 4.4.0 → 4.5.0

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
  SHA256:
3
- metadata.gz: 2ba2d239f123bdb4e182b88d91784524799c70c90bd5c807667f95901892263f
4
- data.tar.gz: bf5e63e363ec5da14af177bb87849c9e00b883c964c18b7ebcb227cae994758a
3
+ metadata.gz: 410e2e2d3f001bb5cb9a42cfd6ad2ae32245fa1cd887cb872dae9473275b3e8b
4
+ data.tar.gz: 5c7b45600a2588bb90f9af55f69c90d61179e9e90ad5481ec97957758ccd1c19
5
5
  SHA512:
6
- metadata.gz: ad9c07a221587403f1d997273b05c121c9fe658113cd3d460f8b1394c17285518cdbbf98cc31865315189bb9402901a23d775003b75760d0c5e7f13b1342d5e5
7
- data.tar.gz: 4f72ebb38c78fd734b235be37a5088c1f632877f592370924dfb89461bd3f4a4f0fe5f8ac85d071c9395467f928b62a530f165cded2718b7c50eb339b5065025
6
+ metadata.gz: 87fcb82185237fd6debabe4adc3b6bc74dc9de74f892c9cfb9103b932df01b6830ec2fb32972c2ebca054505577bbd1643351e64f47f7ae2ff794e57da92c70a
7
+ data.tar.gz: 24959d33b3017e6154cdbef2126eded40c427caa9a4cd3a4335ceabfc53182e7f1515f9a562f0c6f3ab0a9e47052bb4e27d76177b46e2b426ee27b9d8d71f4c9
checksums.yaml.gz.sig CHANGED
Binary file
@@ -13,15 +13,15 @@ module Cloudflare
13
13
  def id
14
14
  result[:id]
15
15
  end
16
-
16
+
17
17
  def kv_namespaces
18
18
  self.with(KV::Namespaces, path: "storage/kv/namespaces")
19
19
  end
20
20
  end
21
-
21
+
22
22
  class Accounts < Representation
23
23
  include Paginate
24
-
24
+
25
25
  def representation
26
26
  Account
27
27
  end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "representation"
4
+ require_relative "paginate"
5
+
6
+ module Cloudflare
7
+ class Certificate < Representation
8
+ def certificate
9
+ result[:certificate]
10
+ end
11
+ end
12
+
13
+ class Certificates < Representation
14
+ include Paginate
15
+
16
+ def representation
17
+ Certificate
18
+ end
19
+
20
+ def create(csr_pem, hostnames, request_type = "origin-rsa", requested_validity = 5475)
21
+ represent_message(self.post({
22
+ csr: csr_pem,
23
+ request_type: request_type,
24
+ hostnames: hostnames,
25
+ requested_validity: requested_validity
26
+ }))
27
+ end
28
+ end
29
+ end
@@ -12,9 +12,11 @@
12
12
 
13
13
  require "async/rest/resource"
14
14
 
15
+ require_relative "ips"
15
16
  require_relative "zones"
16
17
  require_relative "accounts"
17
18
  require_relative "user"
19
+ require_relative "certificates"
18
20
 
19
21
  module Cloudflare
20
22
  class Connection < Async::REST::Resource
@@ -37,6 +39,10 @@ module Cloudflare
37
39
  self.with(headers: headers)
38
40
  end
39
41
 
42
+ def cidrs(ipv: nil)
43
+ IPs.new(self.with(path: "ips")).cidrs(ipv: ipv)
44
+ end
45
+
40
46
  def zones
41
47
  Zones.new(self.with(path: "zones/"))
42
48
  end
@@ -48,5 +54,9 @@ module Cloudflare
48
54
  def user
49
55
  User.new(self.with(path: "user"))
50
56
  end
57
+
58
+ def certificates
59
+ Certificates.new(self.with(path: "certificates"))
60
+ end
51
61
  end
52
62
  end
@@ -13,57 +13,57 @@ module Cloudflare
13
13
  def initialize(settings = {})
14
14
  @settings = settings
15
15
  end
16
-
16
+
17
17
  def ciphers
18
18
  @settings[:ciphers]
19
19
  end
20
-
20
+
21
21
  def ciphers=(value)
22
22
  @settings[:ciphers] = value
23
23
  end
24
-
24
+
25
25
  # This will return the raw value, it is needed because
26
26
  # if a value is nil we can't assume that it means it is off
27
27
  def http2
28
28
  @settings[:http2]
29
29
  end
30
-
30
+
31
31
  # Always coerce into a boolean, if the key is not
32
32
  # provided, this value may not be accurate
33
33
  def http2?
34
34
  http2 == "on"
35
35
  end
36
-
36
+
37
37
  def http2=(value)
38
38
  process_boolean(:http2, value)
39
39
  end
40
-
40
+
41
41
  def min_tls_version
42
42
  @settings[:min_tls_version]
43
43
  end
44
-
44
+
45
45
  def min_tls_version=(value)
46
46
  @settings[:min_tls_version] = value
47
47
  end
48
-
48
+
49
49
  # This will return the raw value, it is needed because
50
50
  # if a value is nil we can't assume that it means it is off
51
51
  def tls_1_3
52
52
  @settings[:tls_1_3]
53
53
  end
54
-
54
+
55
55
  # Always coerce into a boolean, if the key is not
56
56
  # provided, this value may not be accurate
57
57
  def tls_1_3?
58
58
  tls_1_3 == "on"
59
59
  end
60
-
60
+
61
61
  def tls_1_3=(value)
62
62
  process_boolean(:tls_1_3, value)
63
63
  end
64
-
64
+
65
65
  private
66
-
66
+
67
67
  def process_boolean(key, value)
68
68
  if value.nil?
69
69
  @settings.delete(key)
@@ -13,52 +13,52 @@ module Cloudflare
13
13
  def initialize(params)
14
14
  @params = params
15
15
  end
16
-
16
+
17
17
  def active?
18
18
  status == "active"
19
19
  end
20
-
20
+
21
21
  def cname
22
22
  @params[:cname]
23
23
  end
24
-
24
+
25
25
  def cname_target
26
26
  @params[:cname_target]
27
27
  end
28
-
28
+
29
29
  def http_body
30
30
  @params[:http_body]
31
31
  end
32
-
32
+
33
33
  def http_url
34
34
  @params[:http_url]
35
35
  end
36
-
36
+
37
37
  def method
38
38
  @params[:method]
39
39
  end
40
-
40
+
41
41
  def pending_validation?
42
42
  status == "pending_validation"
43
43
  end
44
-
44
+
45
45
  # Wraps the settings hash if it exists or initializes the settings hash and then wraps it
46
46
  def settings
47
47
  @settings ||= Settings.new(@params[:settings] ||= {})
48
48
  end
49
-
49
+
50
50
  def status
51
51
  @params[:status]
52
52
  end
53
-
53
+
54
54
  def to_h
55
55
  @params
56
56
  end
57
-
57
+
58
58
  def type
59
59
  @params[:type]
60
60
  end
61
-
61
+
62
62
  def validation_errors
63
63
  @params[:validation_errors]
64
64
  end
@@ -62,7 +62,7 @@ module Cloudflare
62
62
  self.class.patch(@resource, payload) do |resource, response|
63
63
  value = response.read
64
64
 
65
- if value[:sucess]
65
+ if value[:success]
66
66
  @ssl = nil
67
67
  @value = value
68
68
  else
@@ -71,7 +71,7 @@ module Cloudflare
71
71
  end
72
72
  end
73
73
  end
74
-
74
+
75
75
  class CustomHostnames < Representation
76
76
  include Paginate
77
77
 
@@ -97,7 +97,7 @@ module Cloudflare
97
97
  CustomHostname.new(resource, value: value, metadata: metadata)
98
98
  end
99
99
  end
100
-
100
+
101
101
  def find_by_hostname(hostname)
102
102
  each(hostname: hostname).first
103
103
  end
@@ -76,7 +76,7 @@ module Cloudflare
76
76
  Record.new(resource, value: value, metadata: metadata)
77
77
  end
78
78
  end
79
-
79
+
80
80
  def find_by_name(name)
81
81
  each(name: name).find{|record| record.name == name}
82
82
  end
@@ -28,7 +28,7 @@ module Cloudflare
28
28
  "#{configuration[:value]} - #{mode} - #{notes}"
29
29
  end
30
30
  end
31
-
31
+
32
32
  class Rules < Representation
33
33
  include Paginate
34
34
 
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "representation"
4
+
5
+ module Cloudflare
6
+ class IPs < Representation
7
+ def cidrs(ipv: nil)
8
+ if ipv
9
+ result[:"ipv#{ipv}_cidrs"]
10
+ else
11
+ result[:ipv4_cidrs].to_a + result[:ipv6_cidrs].to_a
12
+ end
13
+ end
14
+ end
15
+ end
@@ -107,7 +107,7 @@ module Cloudflare
107
107
  end
108
108
 
109
109
  def find_by_title(title)
110
- each.find {|namespace| namespace.title == title }
110
+ each.find{|namespace| namespace.title == title}
111
111
  end
112
112
  end
113
113
  end
@@ -27,7 +27,7 @@ module Cloudflare
27
27
  super
28
28
  end
29
29
  end
30
-
30
+
31
31
  class OctetParser < ::Protocol::HTTP::Body::Wrapper
32
32
  def join
33
33
  super.force_encoding(Encoding::BINARY)
@@ -13,7 +13,7 @@ module Cloudflare
13
13
  "#{result[:rayid]}-#{result[:ClientRequestURI]}"
14
14
  end
15
15
  end
16
-
16
+
17
17
  class Received < Representation
18
18
  include Paginate
19
19
 
@@ -10,23 +10,9 @@ require "json"
10
10
  require "async/rest/representation"
11
11
  require "async/rest/wrapper/json"
12
12
 
13
+ require_relative "request_error"
14
+
13
15
  module Cloudflare
14
- class RequestError < StandardError
15
- def initialize(request, value)
16
- if error = value[:error]
17
- super("#{request}: #{error}")
18
- elsif errors = value[:errors]
19
- super("#{request}: #{errors.map{|attributes| attributes[:message]}.join(', ')}")
20
- else
21
- super("#{request}: #{value.inspect}")
22
- end
23
-
24
- @value = value
25
- end
26
-
27
- attr :value
28
- end
29
-
30
16
  class Wrapper < Async::REST::Wrapper::JSON
31
17
  def process_response(request, response)
32
18
  super
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2017-2024, by Samuel Williams.
5
+
6
+ module Cloudflare
7
+ class RequestError < StandardError
8
+ def self.error_string_for(value)
9
+ if value.is_a?(Hash)
10
+ if error = value[:error]
11
+ return error
12
+ elsif errors = value[:errors]
13
+ return errors.map{|attributes| attributes[:message]}.join(", ")
14
+ end
15
+ end
16
+
17
+ return value.inspect
18
+ end
19
+
20
+ def initialize(request, value)
21
+ super("#{request}: #{self.class.error_string_for(value)}")
22
+
23
+ @value = value
24
+ end
25
+
26
+ attr :value
27
+ end
28
+ end
@@ -8,5 +8,5 @@
8
8
  # Copyright, 2018, by Casey Lopez.
9
9
 
10
10
  module Cloudflare
11
- VERSION = "4.4.0"
11
+ VERSION = "4.5.0"
12
12
  end
@@ -11,6 +11,7 @@
11
11
  # Copyright, 2018, by Casey Lopez.
12
12
  # Copyright, 2019, by Akinori Musha.
13
13
  # Copyright, 2019, by Rob Widmer.
14
+ # Copyright, 2025, by Travis Skindzier.
14
15
 
15
16
  require_relative "representation"
16
17
  require_relative "paginate"
@@ -27,7 +28,7 @@ module Cloudflare
27
28
  def custom_hostnames
28
29
  self.with(CustomHostnames, path: "custom_hostnames")
29
30
  end
30
-
31
+
31
32
  def dns_records
32
33
  self.with(DNS::Records, path: "dns_records")
33
34
  end
@@ -52,6 +53,10 @@ module Cloudflare
52
53
  self.class.post(@resource.with(path: "purge_cache"), options)
53
54
  end
54
55
 
56
+ def activation_check
57
+ self.class.put(@resource.with(path: "activation_check"))
58
+ end
59
+
55
60
  def name
56
61
  result[:name]
57
62
  end
@@ -65,7 +70,7 @@ module Cloudflare
65
70
  def representation
66
71
  Zone
67
72
  end
68
-
73
+
69
74
  def create(name, account, jump_start: false, **options)
70
75
  payload = {name: name, account: account.to_id, jump_start: jump_start, **options}
71
76
 
data/license.md CHANGED
@@ -21,6 +21,7 @@ Copyright, 2019, by Fedishin Nazar.
21
21
  Copyright, 2019, by David Wegman.
22
22
  Copyright, 2020, by Olle Jonsson.
23
23
  Copyright, 2021, by Terry Kerr.
24
+ Copyright, 2025, by Travis Skindzier.
24
25
 
25
26
  Permission is hereby granted, free of charge, to any person obtaining a copy
26
27
  of this software and associated documentation files (the "Software"), to deal
data/readme.md CHANGED
@@ -9,7 +9,7 @@ It is a Ruby wrapper for the Cloudflare V4 API. It provides a light weight wrapp
9
9
  Add this line to your application's Gemfile:
10
10
 
11
11
  ``` ruby
12
- gem 'cloudflare'
12
+ gem "cloudflare"
13
13
  ```
14
14
 
15
15
  And then execute:
@@ -25,11 +25,11 @@ Or install it yourself as:
25
25
  Here are some basic examples. For more details, refer to the code and specs.
26
26
 
27
27
  ``` ruby
28
- require 'cloudflare'
28
+ require "cloudflare"
29
29
 
30
30
  # Grab some details from somewhere:
31
- email = ENV['CLOUDFLARE_EMAIL']
32
- key = ENV['CLOUDFLARE_KEY']
31
+ email = ENV["CLOUDFLARE_EMAIL"]
32
+ key = ENV["CLOUDFLARE_KEY"]
33
33
 
34
34
  Cloudflare.connect(key: key, email: email) do |connection|
35
35
  # Get all available zones:
@@ -48,13 +48,13 @@ Cloudflare.connect(key: key, email: email) do |connection|
48
48
 
49
49
  # Add a DNS record. Here we add an A record for `batman.example.com`:
50
50
  zone = zones.find_by_name("example.com")
51
- zone.dns_records.create('A', 'batman', '1.2.3.4', proxied: false)
51
+ zone.dns_records.create("A", "batman", "1.2.3.4", proxied: false)
52
52
 
53
53
  # Get firewall rules:
54
54
  all_rules = zone.firewall_rules
55
55
 
56
56
  # Block an ip:
57
- rule = zone.firewall_rules.set('block', '1.2.3.4', notes: "ssh dictionary attack")
57
+ rule = zone.firewall_rules.set("block", "1.2.3.4", notes: "ssh dictionary attack")
58
58
  end
59
59
  ```
60
60
 
@@ -63,9 +63,9 @@ end
63
63
  You can read more about [bearer tokens here](https://blog.cloudflare.com/api-tokens-general-availability/). This allows you to limit priviledges.
64
64
 
65
65
  ``` ruby
66
- require 'cloudflare'
66
+ require "cloudflare"
67
67
 
68
- token = 'a_generated_api_token'
68
+ token = "a_generated_api_token"
69
69
 
70
70
  Cloudflare.connect(token: token) do |connection|
71
71
  # ...
@@ -76,7 +76,7 @@ end
76
76
 
77
77
  ``` ruby
78
78
  Async do
79
- connection = Cloudflare.connect(...)
79
+ connection = Cloudflare.connect
80
80
 
81
81
  # ... do something with connection ...
82
82
  ensure
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudflare
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.0
4
+ version: 4.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -24,8 +24,8 @@ authors:
24
24
  - Mike Perham
25
25
  - Olle Jonsson
26
26
  - Terry Kerr
27
+ - Travis Skindzier
27
28
  - 莫粒
28
- autorequire:
29
29
  bindir: bin
30
30
  cert_chain:
31
31
  - |
@@ -57,7 +57,7 @@ cert_chain:
57
57
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
58
58
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
59
59
  -----END CERTIFICATE-----
60
- date: 2024-09-13 00:00:00.000000000 Z
60
+ date: 1980-01-02 00:00:00.000000000 Z
61
61
  dependencies:
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: async-rest
@@ -73,25 +73,26 @@ dependencies:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0.18'
76
- description:
77
- email:
78
76
  executables: []
79
77
  extensions: []
80
78
  extra_rdoc_files: []
81
79
  files:
82
80
  - lib/cloudflare.rb
83
81
  - lib/cloudflare/accounts.rb
82
+ - lib/cloudflare/certificates.rb
84
83
  - lib/cloudflare/connection.rb
85
84
  - lib/cloudflare/custom_hostname/ssl_attribute.rb
86
85
  - lib/cloudflare/custom_hostname/ssl_attribute/settings.rb
87
86
  - lib/cloudflare/custom_hostnames.rb
88
87
  - lib/cloudflare/dns.rb
89
88
  - lib/cloudflare/firewall.rb
89
+ - lib/cloudflare/ips.rb
90
90
  - lib/cloudflare/kv/namespaces.rb
91
91
  - lib/cloudflare/kv/wrapper.rb
92
92
  - lib/cloudflare/logs.rb
93
93
  - lib/cloudflare/paginate.rb
94
94
  - lib/cloudflare/representation.rb
95
+ - lib/cloudflare/request_error.rb
95
96
  - lib/cloudflare/user.rb
96
97
  - lib/cloudflare/version.rb
97
98
  - lib/cloudflare/zones.rb
@@ -102,7 +103,6 @@ licenses:
102
103
  - MIT
103
104
  metadata:
104
105
  source_code_uri: https://github.com/socketry/cloudflare.git
105
- post_install_message:
106
106
  rdoc_options: []
107
107
  require_paths:
108
108
  - lib
@@ -110,15 +110,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
110
  requirements:
111
111
  - - ">="
112
112
  - !ruby/object:Gem::Version
113
- version: '3.1'
113
+ version: '3.2'
114
114
  required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  requirements:
116
116
  - - ">="
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  requirements: []
120
- rubygems_version: 3.5.11
121
- signing_key:
120
+ rubygems_version: 4.0.3
122
121
  specification_version: 4
123
122
  summary: A Ruby wrapper for the Cloudflare API.
124
123
  test_files: []
metadata.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- C��`���M�*�?� ��G|5|�t(�G�[ �l�P�4�E�Q�H���K*U3ٿR�a�;8l����
2
- ,sF�ɛbTTz(MJ��[�lj� =�cD��}|��<��
1
+ ����7+ul��ȻSt�>���j��N�\����K'U�� �,if~;OKM����~(
2
+ vH�A���͟�:�YQqb���3Ⱦ� ϸ��s k��V�%�?Qp�����9M�{U;����sRQn �:V2�H����B��[����ؠ