Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

origin certificates setup and back-end CIDRs list; NO SPECS #71

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions lib/cloudflare/certificates.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require_relative 'representation'
require_relative 'paginate'

module Cloudflare

class Certificate < Representation
def certificate
value[:certificate]
end
end

class Certificates < Representation
include Paginate

def representation
Certificate
end

def create(csr_pem, hostnames, request_type = 'origin-rsa', requested_validity = 5475)
attrs =
{csr: csr_pem, request_type: request_type, hostnames: hostnames, requested_validity: requested_validity}
represent_message(self.post(attrs))
end
end
end
10 changes: 10 additions & 0 deletions lib/cloudflare/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@

require_relative 'representation'

require_relative 'i_ps'
require_relative 'zones'
require_relative 'accounts'
require_relative 'user'
require_relative 'certificates'

module Cloudflare
class Connection < Representation
Expand All @@ -44,6 +46,10 @@ def authenticated(token: nil, key: nil, email: nil)

self.with(headers: headers)
end

def cidrs(ipv: nil)
with(IPs, path: 'ips').cidrs(ipv: ipv)
end

def zones
self.with(Zones, path: 'zones')
Expand All @@ -56,5 +62,9 @@ def accounts
def user
self.with(User, path: 'user')
end

def certificates
with(Certificates, path: 'certificates')
end
end
end
13 changes: 13 additions & 0 deletions lib/cloudflare/i_ps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require_relative 'representation'

module Cloudflare
class IPs < Representation
def cidrs(ipv: nil)
if ipv
value[:"ipv#{ipv}_cidrs"]
else
value[:ipv4_cidrs].to_a + value[:ipv6_cidrs].to_a
end
end
end
end