lex-cloudflare 0.1.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 +7 -0
- data/.github/workflows/ci.yml +34 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.rubocop.yml +66 -0
- data/CHANGELOG.md +14 -0
- data/CLAUDE.md +119 -0
- data/Dockerfile +6 -0
- data/Gemfile +12 -0
- data/LICENSE +21 -0
- data/README.md +98 -0
- data/lex-cloudflare.gemspec +30 -0
- data/lib/legion/extensions/cloudflare/ai/client.rb +29 -0
- data/lib/legion/extensions/cloudflare/ai/helpers/client.rb +24 -0
- data/lib/legion/extensions/cloudflare/ai/runners/finetunes.rb +40 -0
- data/lib/legion/extensions/cloudflare/ai/runners/models.rb +44 -0
- data/lib/legion/extensions/cloudflare/ai.rb +15 -0
- data/lib/legion/extensions/cloudflare/ai_gateway/client.rb +33 -0
- data/lib/legion/extensions/cloudflare/ai_gateway/helpers/client.rb +24 -0
- data/lib/legion/extensions/cloudflare/ai_gateway/runners/datasets.rb +44 -0
- data/lib/legion/extensions/cloudflare/ai_gateway/runners/evaluations.rb +39 -0
- data/lib/legion/extensions/cloudflare/ai_gateway/runners/gateways.rb +44 -0
- data/lib/legion/extensions/cloudflare/ai_gateway/runners/logs.rb +49 -0
- data/lib/legion/extensions/cloudflare/ai_gateway.rb +17 -0
- data/lib/legion/extensions/cloudflare/custom_nameservers/client.rb +27 -0
- data/lib/legion/extensions/cloudflare/custom_nameservers/helpers/client.rb +24 -0
- data/lib/legion/extensions/cloudflare/custom_nameservers/runners/nameservers.rb +34 -0
- data/lib/legion/extensions/cloudflare/custom_nameservers.rb +14 -0
- data/lib/legion/extensions/cloudflare/dns/client.rb +29 -0
- data/lib/legion/extensions/cloudflare/dns/helpers/client.rb +24 -0
- data/lib/legion/extensions/cloudflare/dns/runners/dnssec.rb +33 -0
- data/lib/legion/extensions/cloudflare/dns/runners/records.rb +44 -0
- data/lib/legion/extensions/cloudflare/dns.rb +15 -0
- data/lib/legion/extensions/cloudflare/dns_firewall/client.rb +29 -0
- data/lib/legion/extensions/cloudflare/dns_firewall/helpers/client.rb +24 -0
- data/lib/legion/extensions/cloudflare/dns_firewall/runners/analytics.rb +42 -0
- data/lib/legion/extensions/cloudflare/dns_firewall/runners/clusters.rb +45 -0
- data/lib/legion/extensions/cloudflare/dns_firewall.rb +15 -0
- data/lib/legion/extensions/cloudflare/ssl/client.rb +29 -0
- data/lib/legion/extensions/cloudflare/ssl/helpers/client.rb +24 -0
- data/lib/legion/extensions/cloudflare/ssl/runners/certificate_packs.rb +48 -0
- data/lib/legion/extensions/cloudflare/ssl/runners/universal.rb +44 -0
- data/lib/legion/extensions/cloudflare/ssl.rb +15 -0
- data/lib/legion/extensions/cloudflare/vectorize/client.rb +29 -0
- data/lib/legion/extensions/cloudflare/vectorize/helpers/client.rb +24 -0
- data/lib/legion/extensions/cloudflare/vectorize/runners/indexes.rb +61 -0
- data/lib/legion/extensions/cloudflare/vectorize/runners/vectors.rb +49 -0
- data/lib/legion/extensions/cloudflare/vectorize.rb +15 -0
- data/lib/legion/extensions/cloudflare/version.rb +9 -0
- data/lib/legion/extensions/cloudflare/zero_trust/client.rb +33 -0
- data/lib/legion/extensions/cloudflare/zero_trust/helpers/client.rb +24 -0
- data/lib/legion/extensions/cloudflare/zero_trust/runners/devices.rb +39 -0
- data/lib/legion/extensions/cloudflare/zero_trust/runners/dex_tests.rb +44 -0
- data/lib/legion/extensions/cloudflare/zero_trust/runners/ip_profiles.rb +44 -0
- data/lib/legion/extensions/cloudflare/zero_trust/runners/registrations.rb +44 -0
- data/lib/legion/extensions/cloudflare/zero_trust.rb +17 -0
- data/lib/legion/extensions/cloudflare.rb +19 -0
- metadata +116 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Cloudflare
|
|
6
|
+
module AiGateway
|
|
7
|
+
module Runners
|
|
8
|
+
module Datasets
|
|
9
|
+
extend Legion::Extensions::Cloudflare::AiGateway::Helpers::Client
|
|
10
|
+
|
|
11
|
+
def list_datasets(account_id:, gateway_id:, page: nil, per_page: nil, search: nil, **)
|
|
12
|
+
params = { page: page, per_page: per_page, search: search }.compact
|
|
13
|
+
response = client(**).get("/accounts/#{account_id}/ai-gateway/gateways/#{gateway_id}/datasets", params)
|
|
14
|
+
{ result: response.body, status: response.status }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def get_dataset(account_id:, gateway_id:, id:, **)
|
|
18
|
+
response = client(**).get("/accounts/#{account_id}/ai-gateway/gateways/#{gateway_id}/datasets/#{id}")
|
|
19
|
+
{ result: response.body, status: response.status }
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def create_dataset(account_id:, gateway_id:, body:, **)
|
|
23
|
+
response = client(**).post("/accounts/#{account_id}/ai-gateway/gateways/#{gateway_id}/datasets", body)
|
|
24
|
+
{ result: response.body, status: response.status }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def update_dataset(account_id:, gateway_id:, id:, body:, **)
|
|
28
|
+
response = client(**).put("/accounts/#{account_id}/ai-gateway/gateways/#{gateway_id}/datasets/#{id}", body)
|
|
29
|
+
{ result: response.body, status: response.status }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def delete_dataset(account_id:, gateway_id:, id:, **)
|
|
33
|
+
response = client(**).delete("/accounts/#{account_id}/ai-gateway/gateways/#{gateway_id}/datasets/#{id}")
|
|
34
|
+
{ result: response.body, status: response.status }
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
|
|
38
|
+
Legion::Extensions::Helpers.const_defined?(:Lex)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Cloudflare
|
|
6
|
+
module AiGateway
|
|
7
|
+
module Runners
|
|
8
|
+
module Evaluations
|
|
9
|
+
extend Legion::Extensions::Cloudflare::AiGateway::Helpers::Client
|
|
10
|
+
|
|
11
|
+
def list_evaluations(account_id:, gateway_id:, page: nil, per_page: nil, **)
|
|
12
|
+
params = { page: page, per_page: per_page }.compact
|
|
13
|
+
response = client(**).get("/accounts/#{account_id}/ai-gateway/gateways/#{gateway_id}/evaluations", params)
|
|
14
|
+
{ result: response.body, status: response.status }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def get_evaluation(account_id:, gateway_id:, id:, **)
|
|
18
|
+
response = client(**).get("/accounts/#{account_id}/ai-gateway/gateways/#{gateway_id}/evaluations/#{id}")
|
|
19
|
+
{ result: response.body, status: response.status }
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def create_evaluation(account_id:, gateway_id:, body:, **)
|
|
23
|
+
response = client(**).post("/accounts/#{account_id}/ai-gateway/gateways/#{gateway_id}/evaluations", body)
|
|
24
|
+
{ result: response.body, status: response.status }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def delete_evaluation(account_id:, gateway_id:, id:, **)
|
|
28
|
+
response = client(**).delete("/accounts/#{account_id}/ai-gateway/gateways/#{gateway_id}/evaluations/#{id}")
|
|
29
|
+
{ result: response.body, status: response.status }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
|
|
33
|
+
Legion::Extensions::Helpers.const_defined?(:Lex)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Cloudflare
|
|
6
|
+
module AiGateway
|
|
7
|
+
module Runners
|
|
8
|
+
module Gateways
|
|
9
|
+
extend Legion::Extensions::Cloudflare::AiGateway::Helpers::Client
|
|
10
|
+
|
|
11
|
+
def list_gateways(account_id:, page: nil, per_page: nil, search: nil, **)
|
|
12
|
+
params = { page: page, per_page: per_page, search: search }.compact
|
|
13
|
+
response = client(**).get("/accounts/#{account_id}/ai-gateway/gateways", params)
|
|
14
|
+
{ result: response.body, status: response.status }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def get_gateway(account_id:, id:, **)
|
|
18
|
+
response = client(**).get("/accounts/#{account_id}/ai-gateway/gateways/#{id}")
|
|
19
|
+
{ result: response.body, status: response.status }
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def create_gateway(account_id:, body:, **)
|
|
23
|
+
response = client(**).post("/accounts/#{account_id}/ai-gateway/gateways", body)
|
|
24
|
+
{ result: response.body, status: response.status }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def update_gateway(account_id:, id:, body:, **)
|
|
28
|
+
response = client(**).put("/accounts/#{account_id}/ai-gateway/gateways/#{id}", body)
|
|
29
|
+
{ result: response.body, status: response.status }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def delete_gateway(account_id:, id:, **)
|
|
33
|
+
response = client(**).delete("/accounts/#{account_id}/ai-gateway/gateways/#{id}")
|
|
34
|
+
{ result: response.body, status: response.status }
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
|
|
38
|
+
Legion::Extensions::Helpers.const_defined?(:Lex)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Cloudflare
|
|
6
|
+
module AiGateway
|
|
7
|
+
module Runners
|
|
8
|
+
module Logs
|
|
9
|
+
extend Legion::Extensions::Cloudflare::AiGateway::Helpers::Client
|
|
10
|
+
|
|
11
|
+
def list_logs(account_id:, gateway_id:, page: nil, per_page: nil, **)
|
|
12
|
+
params = { page: page, per_page: per_page }.compact
|
|
13
|
+
response = client(**).get("/accounts/#{account_id}/ai-gateway/gateways/#{gateway_id}/logs", params)
|
|
14
|
+
{ result: response.body, status: response.status }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def get_log(account_id:, gateway_id:, id:, **)
|
|
18
|
+
response = client(**).get("/accounts/#{account_id}/ai-gateway/gateways/#{gateway_id}/logs/#{id}")
|
|
19
|
+
{ result: response.body, status: response.status }
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def patch_log(account_id:, gateway_id:, id:, body:, **)
|
|
23
|
+
response = client(**).patch("/accounts/#{account_id}/ai-gateway/gateways/#{gateway_id}/logs/#{id}", body)
|
|
24
|
+
{ result: response.body, status: response.status }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def delete_logs(account_id:, gateway_id:, **)
|
|
28
|
+
response = client(**).delete("/accounts/#{account_id}/ai-gateway/gateways/#{gateway_id}/logs")
|
|
29
|
+
{ result: response.body, status: response.status }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def get_log_request(account_id:, gateway_id:, id:, **)
|
|
33
|
+
response = client(**).get("/accounts/#{account_id}/ai-gateway/gateways/#{gateway_id}/logs/#{id}/request")
|
|
34
|
+
{ result: response.body, status: response.status }
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def get_log_response(account_id:, gateway_id:, id:, **)
|
|
38
|
+
response = client(**).get("/accounts/#{account_id}/ai-gateway/gateways/#{gateway_id}/logs/#{id}/response")
|
|
39
|
+
{ result: response.body, status: response.status }
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
|
|
43
|
+
Legion::Extensions::Helpers.const_defined?(:Lex)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/cloudflare/ai_gateway/helpers/client'
|
|
4
|
+
require 'legion/extensions/cloudflare/ai_gateway/runners/gateways'
|
|
5
|
+
require 'legion/extensions/cloudflare/ai_gateway/runners/logs'
|
|
6
|
+
require 'legion/extensions/cloudflare/ai_gateway/runners/datasets'
|
|
7
|
+
require 'legion/extensions/cloudflare/ai_gateway/runners/evaluations'
|
|
8
|
+
require 'legion/extensions/cloudflare/ai_gateway/client'
|
|
9
|
+
|
|
10
|
+
module Legion
|
|
11
|
+
module Extensions
|
|
12
|
+
module Cloudflare
|
|
13
|
+
module AiGateway
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'helpers/client'
|
|
4
|
+
require_relative 'runners/nameservers'
|
|
5
|
+
|
|
6
|
+
module Legion
|
|
7
|
+
module Extensions
|
|
8
|
+
module Cloudflare
|
|
9
|
+
module CustomNameservers
|
|
10
|
+
class Client
|
|
11
|
+
include Helpers::Client
|
|
12
|
+
include Runners::Nameservers
|
|
13
|
+
|
|
14
|
+
attr_reader :opts
|
|
15
|
+
|
|
16
|
+
def initialize(api_token:, **extra)
|
|
17
|
+
@opts = { api_token: api_token, **extra }.compact
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def client(**override)
|
|
21
|
+
super(**@opts, **override)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'faraday'
|
|
4
|
+
|
|
5
|
+
module Legion
|
|
6
|
+
module Extensions
|
|
7
|
+
module Cloudflare
|
|
8
|
+
module CustomNameservers
|
|
9
|
+
module Helpers
|
|
10
|
+
module Client
|
|
11
|
+
def client(api_token:, **)
|
|
12
|
+
Faraday.new(url: 'https://api.cloudflare.com/client/v4') do |conn|
|
|
13
|
+
conn.request :json
|
|
14
|
+
conn.response :json, content_type: /\bjson$/
|
|
15
|
+
conn.headers['Content-Type'] = 'application/json'
|
|
16
|
+
conn.headers['Authorization'] = "Bearer #{api_token}"
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Cloudflare
|
|
6
|
+
module CustomNameservers
|
|
7
|
+
module Runners
|
|
8
|
+
module Nameservers
|
|
9
|
+
extend Legion::Extensions::Cloudflare::CustomNameservers::Helpers::Client
|
|
10
|
+
|
|
11
|
+
def list(account_id:, **)
|
|
12
|
+
response = client(**).get("/accounts/#{account_id}/custom_ns")
|
|
13
|
+
{ result: response.body, status: response.status }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def add(account_id:, ns_name:, ns_set: nil, **)
|
|
17
|
+
body = { ns_name: ns_name, ns_set: ns_set }.compact
|
|
18
|
+
response = client(**).post("/accounts/#{account_id}/custom_ns", body)
|
|
19
|
+
{ result: response.body, status: response.status }
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def delete(account_id:, custom_ns_id:, **)
|
|
23
|
+
response = client(**).delete("/accounts/#{account_id}/custom_ns/#{custom_ns_id}")
|
|
24
|
+
{ result: response.body, status: response.status }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
|
|
28
|
+
Legion::Extensions::Helpers.const_defined?(:Lex)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/cloudflare/custom_nameservers/helpers/client'
|
|
4
|
+
require 'legion/extensions/cloudflare/custom_nameservers/runners/nameservers'
|
|
5
|
+
require 'legion/extensions/cloudflare/custom_nameservers/client'
|
|
6
|
+
|
|
7
|
+
module Legion
|
|
8
|
+
module Extensions
|
|
9
|
+
module Cloudflare
|
|
10
|
+
module CustomNameservers
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'helpers/client'
|
|
4
|
+
require_relative 'runners/records'
|
|
5
|
+
require_relative 'runners/dnssec'
|
|
6
|
+
|
|
7
|
+
module Legion
|
|
8
|
+
module Extensions
|
|
9
|
+
module Cloudflare
|
|
10
|
+
module Dns
|
|
11
|
+
class Client
|
|
12
|
+
include Helpers::Client
|
|
13
|
+
include Runners::Records
|
|
14
|
+
include Runners::Dnssec
|
|
15
|
+
|
|
16
|
+
attr_reader :opts
|
|
17
|
+
|
|
18
|
+
def initialize(api_token:, **extra)
|
|
19
|
+
@opts = { api_token: api_token, **extra }.compact
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def client(**override)
|
|
23
|
+
super(**@opts, **override)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'faraday'
|
|
4
|
+
|
|
5
|
+
module Legion
|
|
6
|
+
module Extensions
|
|
7
|
+
module Cloudflare
|
|
8
|
+
module Dns
|
|
9
|
+
module Helpers
|
|
10
|
+
module Client
|
|
11
|
+
def client(api_token:, **)
|
|
12
|
+
Faraday.new(url: 'https://api.cloudflare.com/client/v4') do |conn|
|
|
13
|
+
conn.request :json
|
|
14
|
+
conn.response :json, content_type: /\bjson$/
|
|
15
|
+
conn.headers['Content-Type'] = 'application/json'
|
|
16
|
+
conn.headers['Authorization'] = "Bearer #{api_token}"
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Cloudflare
|
|
6
|
+
module Dns
|
|
7
|
+
module Runners
|
|
8
|
+
module Dnssec
|
|
9
|
+
extend Legion::Extensions::Cloudflare::Dns::Helpers::Client
|
|
10
|
+
|
|
11
|
+
def get_dnssec(zone_id:, **)
|
|
12
|
+
response = client(**).get("/zones/#{zone_id}/dnssec")
|
|
13
|
+
{ result: response.body, status: response.status }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def edit_dnssec(zone_id:, body:, **)
|
|
17
|
+
response = client(**).patch("/zones/#{zone_id}/dnssec", body)
|
|
18
|
+
{ result: response.body, status: response.status }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def delete_dnssec(zone_id:, **)
|
|
22
|
+
response = client(**).delete("/zones/#{zone_id}/dnssec")
|
|
23
|
+
{ result: response.body, status: response.status }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
|
|
27
|
+
Legion::Extensions::Helpers.const_defined?(:Lex)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Cloudflare
|
|
6
|
+
module Dns
|
|
7
|
+
module Runners
|
|
8
|
+
module Records
|
|
9
|
+
extend Legion::Extensions::Cloudflare::Dns::Helpers::Client
|
|
10
|
+
|
|
11
|
+
def list(zone_id:, type: nil, name: nil, page: nil, per_page: nil, **)
|
|
12
|
+
params = { type: type, name: name, page: page, per_page: per_page }.compact
|
|
13
|
+
response = client(**).get("/zones/#{zone_id}/dns_records", params)
|
|
14
|
+
{ result: response.body, status: response.status }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def get(zone_id:, dns_record_id:, **)
|
|
18
|
+
response = client(**).get("/zones/#{zone_id}/dns_records/#{dns_record_id}")
|
|
19
|
+
{ result: response.body, status: response.status }
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def create(zone_id:, body:, **)
|
|
23
|
+
response = client(**).post("/zones/#{zone_id}/dns_records", body)
|
|
24
|
+
{ result: response.body, status: response.status }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def update(zone_id:, dns_record_id:, body:, **)
|
|
28
|
+
response = client(**).patch("/zones/#{zone_id}/dns_records/#{dns_record_id}", body)
|
|
29
|
+
{ result: response.body, status: response.status }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def delete(zone_id:, dns_record_id:, **)
|
|
33
|
+
response = client(**).delete("/zones/#{zone_id}/dns_records/#{dns_record_id}")
|
|
34
|
+
{ result: response.body, status: response.status }
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
|
|
38
|
+
Legion::Extensions::Helpers.const_defined?(:Lex)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/cloudflare/dns/helpers/client'
|
|
4
|
+
require 'legion/extensions/cloudflare/dns/runners/records'
|
|
5
|
+
require 'legion/extensions/cloudflare/dns/runners/dnssec'
|
|
6
|
+
require 'legion/extensions/cloudflare/dns/client'
|
|
7
|
+
|
|
8
|
+
module Legion
|
|
9
|
+
module Extensions
|
|
10
|
+
module Cloudflare
|
|
11
|
+
module Dns
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'helpers/client'
|
|
4
|
+
require_relative 'runners/clusters'
|
|
5
|
+
require_relative 'runners/analytics'
|
|
6
|
+
|
|
7
|
+
module Legion
|
|
8
|
+
module Extensions
|
|
9
|
+
module Cloudflare
|
|
10
|
+
module DnsFirewall
|
|
11
|
+
class Client
|
|
12
|
+
include Helpers::Client
|
|
13
|
+
include Runners::Clusters
|
|
14
|
+
include Runners::Analytics
|
|
15
|
+
|
|
16
|
+
attr_reader :opts
|
|
17
|
+
|
|
18
|
+
def initialize(api_token:, **extra)
|
|
19
|
+
@opts = { api_token: api_token, **extra }.compact
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def client(**override)
|
|
23
|
+
super(**@opts, **override)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'faraday'
|
|
4
|
+
|
|
5
|
+
module Legion
|
|
6
|
+
module Extensions
|
|
7
|
+
module Cloudflare
|
|
8
|
+
module DnsFirewall
|
|
9
|
+
module Helpers
|
|
10
|
+
module Client
|
|
11
|
+
def client(api_token:, **)
|
|
12
|
+
Faraday.new(url: 'https://api.cloudflare.com/client/v4') do |conn|
|
|
13
|
+
conn.request :json
|
|
14
|
+
conn.response :json, content_type: /\bjson$/
|
|
15
|
+
conn.headers['Content-Type'] = 'application/json'
|
|
16
|
+
conn.headers['Authorization'] = "Bearer #{api_token}"
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Cloudflare
|
|
6
|
+
module DnsFirewall
|
|
7
|
+
module Runners
|
|
8
|
+
module Analytics
|
|
9
|
+
extend Legion::Extensions::Cloudflare::DnsFirewall::Helpers::Client
|
|
10
|
+
|
|
11
|
+
def report(account_id:, dns_firewall_id:, **)
|
|
12
|
+
response = client(**).get("/accounts/#{account_id}/dns_firewall/#{dns_firewall_id}/dns_analytics/report")
|
|
13
|
+
{ result: response.body, status: response.status }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def report_by_time(account_id:, dns_firewall_id:, time_delta: nil, **)
|
|
17
|
+
params = { time_delta: time_delta }.compact
|
|
18
|
+
response = client(**).get(
|
|
19
|
+
"/accounts/#{account_id}/dns_firewall/#{dns_firewall_id}/dns_analytics/report/bytime",
|
|
20
|
+
params
|
|
21
|
+
)
|
|
22
|
+
{ result: response.body, status: response.status }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def get_reverse_dns(account_id:, dns_firewall_id:, **)
|
|
26
|
+
response = client(**).get("/accounts/#{account_id}/dns_firewall/#{dns_firewall_id}/reverse_dns")
|
|
27
|
+
{ result: response.body, status: response.status }
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def update_reverse_dns(account_id:, dns_firewall_id:, body:, **)
|
|
31
|
+
response = client(**).patch("/accounts/#{account_id}/dns_firewall/#{dns_firewall_id}/reverse_dns", body)
|
|
32
|
+
{ result: response.body, status: response.status }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
|
|
36
|
+
Legion::Extensions::Helpers.const_defined?(:Lex)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Cloudflare
|
|
6
|
+
module DnsFirewall
|
|
7
|
+
module Runners
|
|
8
|
+
module Clusters
|
|
9
|
+
extend Legion::Extensions::Cloudflare::DnsFirewall::Helpers::Client
|
|
10
|
+
|
|
11
|
+
def list(account_id:, page: nil, per_page: nil, **)
|
|
12
|
+
params = { page: page, per_page: per_page }.compact
|
|
13
|
+
response = client(**).get("/accounts/#{account_id}/dns_firewall", params)
|
|
14
|
+
{ result: response.body, status: response.status }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def get(account_id:, dns_firewall_id:, **)
|
|
18
|
+
response = client(**).get("/accounts/#{account_id}/dns_firewall/#{dns_firewall_id}")
|
|
19
|
+
{ result: response.body, status: response.status }
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def create(account_id:, name:, upstream_ips:, **extra)
|
|
23
|
+
body = { name: name, upstream_ips: upstream_ips, **extra }.compact
|
|
24
|
+
response = client(**extra).post("/accounts/#{account_id}/dns_firewall", body)
|
|
25
|
+
{ result: response.body, status: response.status }
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def update(account_id:, dns_firewall_id:, body:, **)
|
|
29
|
+
response = client(**).patch("/accounts/#{account_id}/dns_firewall/#{dns_firewall_id}", body)
|
|
30
|
+
{ result: response.body, status: response.status }
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def delete(account_id:, dns_firewall_id:, **)
|
|
34
|
+
response = client(**).delete("/accounts/#{account_id}/dns_firewall/#{dns_firewall_id}")
|
|
35
|
+
{ result: response.body, status: response.status }
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
|
|
39
|
+
Legion::Extensions::Helpers.const_defined?(:Lex)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/cloudflare/dns_firewall/helpers/client'
|
|
4
|
+
require 'legion/extensions/cloudflare/dns_firewall/runners/clusters'
|
|
5
|
+
require 'legion/extensions/cloudflare/dns_firewall/runners/analytics'
|
|
6
|
+
require 'legion/extensions/cloudflare/dns_firewall/client'
|
|
7
|
+
|
|
8
|
+
module Legion
|
|
9
|
+
module Extensions
|
|
10
|
+
module Cloudflare
|
|
11
|
+
module DnsFirewall
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'helpers/client'
|
|
4
|
+
require_relative 'runners/certificate_packs'
|
|
5
|
+
require_relative 'runners/universal'
|
|
6
|
+
|
|
7
|
+
module Legion
|
|
8
|
+
module Extensions
|
|
9
|
+
module Cloudflare
|
|
10
|
+
module Ssl
|
|
11
|
+
class Client
|
|
12
|
+
include Helpers::Client
|
|
13
|
+
include Runners::CertificatePacks
|
|
14
|
+
include Runners::Universal
|
|
15
|
+
|
|
16
|
+
attr_reader :opts
|
|
17
|
+
|
|
18
|
+
def initialize(api_token:, **extra)
|
|
19
|
+
@opts = { api_token: api_token, **extra }.compact
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def client(**override)
|
|
23
|
+
super(**@opts, **override)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'faraday'
|
|
4
|
+
|
|
5
|
+
module Legion
|
|
6
|
+
module Extensions
|
|
7
|
+
module Cloudflare
|
|
8
|
+
module Ssl
|
|
9
|
+
module Helpers
|
|
10
|
+
module Client
|
|
11
|
+
def client(api_token:, **)
|
|
12
|
+
Faraday.new(url: 'https://api.cloudflare.com/client/v4') do |conn|
|
|
13
|
+
conn.request :json
|
|
14
|
+
conn.response :json, content_type: /\bjson$/
|
|
15
|
+
conn.headers['Content-Type'] = 'application/json'
|
|
16
|
+
conn.headers['Authorization'] = "Bearer #{api_token}"
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|