Class: Cloudflare::Connection

Inherits:
Async::REST::Resource
  • Object
show all
Defined in:
lib/cloudflare/connection.rb

Constant Summary collapse

ENDPOINT =
Async::HTTP::Endpoint.parse("https://api.cloudflare.com/client/v4/")

Instance Method Summary collapse

Instance Method Details

#accounts ⇒ Object



50
51
52
# File 'lib/cloudflare/connection.rb', line 50

def accounts
	Accounts.new(self.with(path: "accounts"))
end

#authenticated(token: nil, key: nil, email: nil) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/cloudflare/connection.rb', line 25

def authenticated(token: nil, key: nil, email: nil)
	headers = {}
	
	if token
		headers["authorization"] = "bearer #{token}"
	elsif key
		if email
			headers["x-auth-key"] = key
			headers["x-auth-email"] = email
		else
			headers["x-auth-user-service-key"] = key
		end
	end
	
	self.with(headers: headers)
end

#certificates ⇒ Object



58
59
60
# File 'lib/cloudflare/connection.rb', line 58

def certificates
	Certificates.new(self.with(path: "certificates"))
end

#cidrs(ipv: nil) ⇒ Object



42
43
44
# File 'lib/cloudflare/connection.rb', line 42

def cidrs(ipv: nil)
	IPs.new(self.with(path: "ips")).cidrs(ipv: ipv)
end

#user ⇒ Object



54
55
56
# File 'lib/cloudflare/connection.rb', line 54

def user
	User.new(self.with(path: "user"))
end

#zones ⇒ Object



46
47
48
# File 'lib/cloudflare/connection.rb', line 46

def zones
	Zones.new(self.with(path: "zones/"))
end