class Crowbar::Client::Util::ApiVersion

Attributes

version[RW]

Public Class Methods

default() click to toggle source
# File lib/crowbar/client/util/apiversion.rb, line 42
def default
  os_release = OsRelease.fields

  return 1.0 if os_release["VERSION_ID"] == "12.1" && os_release["ID"] == "sles"

  2.0
end
new(version) click to toggle source
# File lib/crowbar/client/util/apiversion.rb, line 23
def initialize(version)
  @version = version
end

Public Instance Methods

headers() click to toggle source
# File lib/crowbar/client/util/apiversion.rb, line 27
def headers
  if version == 1.0
    {
      "Accept" => "application/json",
      "Content-Type" => "application/json"
    }
  else
    {
      "Accept" => "application/vnd.crowbar.v#{version}+json",
      "Content-Type" => "application/json"
    }
  end
end