This directory hosts The Generator, a tool that generates the classes for each API endpoint from the Elasticsearch REST API JSON Specification.
To generate the code, you need to run (from this folder):
$ thor api:code:generate
- The oss Ruby code will be generated in
elasticsearch-api/lib/elasticsearch/api/actions
. - The xpack Ruby code will be generated in
elasticsearch-xpack/lib/elasticsearch/xpack/api/actions
. - The generator runs Rubocop to autolint and clean up the generated files.
Alternatively, you can pass in oss
or xpack
as parameters to generate only one of the 2 sets of endpoints:
$ thor api:code:generate --api=xpack
$ thor api:code:generate --api=oss
The main entry point is generate_source.rb
, which contains a class that implements a Thor task: generate
:
$ thor api:code:generate
It uses Thor::Actions' template
method and templates/method.erb
to generate the final code. The generator
directory contains some helpers used to generate the code. The ERB template is split into partials and you can find all ERB files in the templates
directory.
There's also a lister task:
$ thor api:list
It's implemented in lister.rb
and it lists all the REST API endpoints from the JSON specification.