Skip to content

Commit

Permalink
Merge d1953b5 into bf90978
Browse files Browse the repository at this point in the history
  • Loading branch information
rdubya committed Mar 27, 2019
2 parents bf90978 + d1953b5 commit 1ff81dc
Show file tree
Hide file tree
Showing 11 changed files with 535 additions and 295 deletions.
14 changes: 10 additions & 4 deletions lib/cloudflare/accounts.rb
Expand Up @@ -24,9 +24,19 @@

require_relative 'representation'
require_relative 'paginate'
require_relative 'kv/namespaces'

module Cloudflare
class Account < Representation

def id
value[:id]
end

def kv_namespaces
KV::Namespaces.new(@resource.with(path: 'storage/kv/namespaces'))
end

end

class Accounts < Representation
Expand All @@ -36,9 +46,5 @@ def representation
Account
end

def create(name)
represent_message(self.post(name: name))
end

end
end
88 changes: 44 additions & 44 deletions lib/cloudflare/custom_hostname/ssl_attribute.rb
Expand Up @@ -4,65 +4,65 @@

module Cloudflare

class CustomHostname < Representation
class CustomHostname < Representation

class SSLAttribute
class SSLAttribute

def initialize(params)
@params = params
end
def initialize(params)
@params = params
end

def active?
status == 'active'
end
def active?
status == 'active'
end

def cname
@params[:cname]
end
def cname
@params[:cname]
end

def cname_target
@params[:cname_target]
end
def cname_target
@params[:cname_target]
end

def http_body
@params[:http_body]
end
def http_body
@params[:http_body]
end

def http_url
@params[:http_url]
end
def http_url
@params[:http_url]
end

def method
@params[:method]
end
def method
@params[:method]
end

def pending_validation?
status == 'pending_validation'
end
def pending_validation?
status == 'pending_validation'
end

# Wraps the settings hash if it exists or initializes the settings hash and then wraps it
def settings
@settings ||= Settings.new(@params[:settings] ||= {})
end
# Wraps the settings hash if it exists or initializes the settings hash and then wraps it
def settings
@settings ||= Settings.new(@params[:settings] ||= {})
end

def status
@params[:status]
end
def status
@params[:status]
end

def to_h
@params
end
def to_h
@params
end

def type
@params[:type]
end
def type
@params[:type]
end

def validation_errors
@params[:validation_errors]
end
def validation_errors
@params[:validation_errors]
end

end
end

end
end

end
142 changes: 71 additions & 71 deletions lib/cloudflare/custom_hostname/ssl_attribute/settings.rb
Expand Up @@ -2,75 +2,75 @@

module Cloudflare

class CustomHostname < Representation

class SSLAttribute

class Settings

def initialize(settings)
@settings = settings
end

def ciphers
@settings[:ciphers]
end

def ciphers=(value)
@settings[:ciphers] = value
end

# This will return the raw value, it is needed because
# if a value is nil we can't assume that it means it is off
def http2
@settings[:http2]
end

# Always coerce into a boolean, if the key is not
# provided, this value may not be accurate
def http2?
http2 == 'on'
end

def http2=(value)
process_boolean(:http2, value)
end

def min_tls_version
@settings[:min_tls_version]
end

def min_tls_version=(value)
@settings[:min_tls_version] = value
end

# This will return the raw value, it is needed because
# if a value is nil we can't assume that it means it is off
def tls_1_3
@settings[:tls_1_3]
end

# Always coerce into a boolean, if the key is not
# provided, this value may not be accurate
def tls_1_3?
tls_1_3 == 'on'
end

def tls_1_3=(value)
process_boolean(:tls_1_3, value)
end

private

def process_boolean(key, value)
if value.nil?
@settings.delete(key)
else
@settings[key] = !value || value == 'off' ? 'off' : 'on'
end
end

end
end
end
class CustomHostname < Representation

class SSLAttribute

class Settings

def initialize(settings)
@settings = settings
end

def ciphers
@settings[:ciphers]
end

def ciphers=(value)
@settings[:ciphers] = value
end

# This will return the raw value, it is needed because
# if a value is nil we can't assume that it means it is off
def http2
@settings[:http2]
end

# Always coerce into a boolean, if the key is not
# provided, this value may not be accurate
def http2?
http2 == 'on'
end

def http2=(value)
process_boolean(:http2, value)
end

def min_tls_version
@settings[:min_tls_version]
end

def min_tls_version=(value)
@settings[:min_tls_version] = value
end

# This will return the raw value, it is needed because
# if a value is nil we can't assume that it means it is off
def tls_1_3
@settings[:tls_1_3]
end

# Always coerce into a boolean, if the key is not
# provided, this value may not be accurate
def tls_1_3?
tls_1_3 == 'on'
end

def tls_1_3=(value)
process_boolean(:tls_1_3, value)
end

private

def process_boolean(key, value)
if value.nil?
@settings.delete(key)
else
@settings[key] = !value || value == 'off' ? 'off' : 'on'
end
end

end
end
end
end

0 comments on commit 1ff81dc

Please sign in to comment.