Class: Cloudflare::CustomHostnames

Inherits:
Representation
  • Object
show all
Includes:
Paginate
Defined in:
lib/cloudflare/custom_hostnames.rb

Constant Summary

Constants inherited from Representation

Representation::WRAPPER

Instance Method Summary collapse

Methods included from Paginate

#each, #empty?, #find_by_id

Methods inherited from Representation

#errors, #messages, #represent, #represent_message, #result, #results, #success?, #to_hash, #to_id

Instance Method Details

#create(hostname, metadata: nil, origin: nil, ssl: {}, **options) ⇒ Object



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/cloudflare/custom_hostnames.rb', line 82

def create(hostname, metadata: nil, origin: nil, ssl: {}, **options)
	payload = {hostname: hostname, ssl: {method: "http", type: "dv"}.merge(ssl), **options}
	
	payload[:custom_metadata] =  if 
	payload[:custom_origin_server] = origin if origin
	
	CustomHostname.post(@resource, payload) do |resource, response|
		value = response.read
		result = value[:result]
		 = response.headers
		
		if id = result[:id]
			resource = resource.with(path: id)
		end
		
		CustomHostname.new(resource, value: value, metadata: )
	end
end

#find_by_hostname(hostname) ⇒ Object



101
102
103
# File 'lib/cloudflare/custom_hostnames.rb', line 101

def find_by_hostname(hostname)
	each(hostname: hostname).first
end

#representationObject



78
79
80
# File 'lib/cloudflare/custom_hostnames.rb', line 78

def representation
	CustomHostname
end