Sha256: 927928b10f56bf13f39f5f9dc097b5da8945fbd27ebe80018018c556a8d273a7

Contents?: true

Size: 1.43 KB

Versions: 22

Compression:

Stored size: 1.43 KB

Contents

# Utils

## The Generator

This directory hosts The Generator, a tool that generates the classes for each API endpoint from the [Elasticsearch REST API JSON Specification](https://github.com/elastic/elasticsearch/tree/master/rest-api-spec).

### Generate

To generate the code, you need to run (from this folder):
```bash
$ 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:

```bash
$ thor api:code:generate --api=xpack
$ thor api:code:generate --api=oss
```

### Development

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](https://github.com/erikhuda/thor/wiki/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.

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
elasticsearch-api-7.14.0.pre utils/README.md
elasticsearch-api-7.13.3 utils/README.md
elasticsearch-api-7.13.1 utils/README.md
elasticsearch-api-7.13.0 utils/README.md
elasticsearch-api-7.13.0.pre utils/README.md
elasticsearch-api-7.12.0 utils/README.md
elasticsearch-api-7.11.2 utils/README.md
elasticsearch-api-7.11.1 utils/README.md
elasticsearch-api-7.11.0 utils/README.md
elasticsearch-api-7.11.0.pre.1 utils/README.md
elasticsearch-api-7.10.1 utils/README.md
elasticsearch-api-7.10.0 utils/README.md
elasticsearch-api-7.10.0.pre utils/README.md
elasticsearch-api-7.9.0 utils/README.md
elasticsearch-api-7.8.1 utils/README.md
elasticsearch-api-7.9.0.pre utils/README.md
elasticsearch-api-7.8.0 utils/README.md
elasticsearch-api-7.8.0.pre utils/README.md
elasticsearch-api-7.7.0 utils/README.md
elasticsearch-api-7.7.0.pre utils/README.md