module OpenShift::Controller::ApiBehavior

Constants

API_VERSION
SUPPORTED_API_VERSIONS

Attributes

requested_api_version[R]

Protected Instance Methods

check_version() click to toggle source
# File lib/openshift/controller/api_behavior.rb, line 16
def check_version
  version = catch(:version) do
    (request.accept || "").split(',').each do |mime_type|
      values = mime_type.split(';').map(&:strip)
      @nolinks = true if values.include? 'nolinks'
      values.map(&:strip).map(&:downcase).each do |value|
        throw :version, value.split("=")[1].to_f if value.starts_with? "version"
      end
    end
    nil
  end.presence || API_VERSION

  if SUPPORTED_API_VERSIONS.include? version
    @requested_api_version = version
  else
    @requested_api_version = API_VERSION
    render_error(:not_acceptable, "Requested API version #{version} is not supported. Supported versions are #{SUPPORTED_API_VERSIONS.map{|v| v.to_s}.join(",")}")
  end
end
get_bool(param_value) click to toggle source
# File lib/openshift/controller/api_behavior.rb, line 54
def get_bool(param_value)
  return false unless param_value
  if param_value.is_a? TrueClass or param_value.is_a? FalseClass
    return param_value
  elsif param_value.is_a? String and param_value.upcase == "TRUE"
    return true
  elsif param_value.is_a? String and param_value.upcase == "FALSE"
    return false
  end
  raise OpenShift::OOException.new("Invalid value '#{param_value}'. Valid options: [true, false]", 167)
end
get_url() click to toggle source
# File lib/openshift/controller/api_behavior.rb, line 36
def get_url
  @rest_url ||= "#{rest_url}/"
end
new_rest_reply(*arguments) click to toggle source
# File lib/openshift/controller/api_behavior.rb, line 12
def new_rest_reply(*arguments)
  RestReply.new(requested_api_version, *arguments)
end
set_locale() click to toggle source
# File lib/openshift/controller/api_behavior.rb, line 40
def set_locale
  I18n.locale = nil
end