module Elastomer::Client::RestApiSpec

Provides access to the versioned REST API specs for Elasticsearch.

Generated REST API spec file - DO NOT EDIT! Date: 2018-01-10 ES version: 2.3

Generated REST API spec file - DO NOT EDIT! Date: 2018-01-10 ES version: 2.4

Generated REST API spec file - DO NOT EDIT! Date: 2018-01-10 ES version: 5.6

Public Class Methods

api_spec(version) click to toggle source

Returns an ApiSpec instance for the given Elasticsearcion version. This method will load the ApiSpec version class if it has not already been defined. This prevents bloat by only loading the version specs that are needed.

Because of this lazy loading, this method is not thread safe.

version - the Elasticsearch version String

Returns the requested ApiSpec version if available

# File lib/elastomer/client/rest_api_spec.rb, line 18
def self.api_spec(version)
  classname = "ApiSpecV#{to_class_version(version)}"
  load_api_spec(version) if !self.const_defined? classname
  self.const_get(classname).new
end
load_api_spec(version) click to toggle source

Internal: Load the specific ApiSpec version class for the given version.

# File lib/elastomer/client/rest_api_spec.rb, line 25
def self.load_api_spec(version)
  path = File.expand_path("../rest_api_spec/api_spec_v#{to_class_version(version)}.rb", __FILE__)
  if File.exist? path
    load path
  else
    raise RuntimeError, "Unsupported REST API spec version: #{version}"
  end
end
to_class_version(version) click to toggle source

Internal: Convert a dotted version String into an underscore format suitable for use in Ruby class names.

# File lib/elastomer/client/rest_api_spec.rb, line 36
def self.to_class_version(version)
  version.to_s.split(".").slice(0,2).join("_")
end