<commit_before># Triton

Gem to wrap and mock the Triton internal APIs.

Currently supports:

 * Vmapi
 * Cnapi
 * Napi
 * Papi
 * Imgapi

## Usage

This library simply exposes the internal Triton API layer as cleaner Ruby function calls with a consistent interface. Rather than re-implement and re-document all the calls, a relatively small set of conventions map the function calls to the HTTP requests allowing the the Joyent documentation to be used directly.

    https://github.com/joyent/sdc-vmapi/blob/master/docs/index.md

### Configuration

When making requests, it calls APIs via their hostnames the suffix needs to be specified. This is dependent on the configuration of the triton cluster. You'll also need access to the Triton `admin` network to make the calls - you can either use this library on a host directly connected to the `admin` network or, alternatively, make calls via a SOCKS proxy.

It's possible to use the SOCKS proxy built into the `ssh` client:

    ssh -D 1234 root@<headnode ip>

    ...

    Triton.socks = '127.0.0.1:1234'

### Calling methods

Each (supported) API has a module under the `Triton` namespace - CNAPI, for example, becomes `Triton::Cnapi`. Each API function can be accessed either via the execute method using CamelCase method name from the Joyent documentation:

  > Triton::Vmapi.execute("ListVms", :fields => 'uuid')
  => [{"uuid"=>"ff64a98e-3a8a-4d90-a726-0c2fd33e378c"}, ...<commit_msg>Rejig documentation links in the README.<commit_after># Triton

Gem to wrap and mock the Triton internal APIs.

Currently supports:

 * [Vmapi](https://github.com/joyent/sdc-vmapi/blob/master/docs/index.md)
 * [Cnapi](https://github.com/joyent/sdc-cnapi/blob/master/docs/index.md)
 * [Napi](https://github.com/joyent/sdc-napi/blob/master/docs/index.md)
 * [Papi](https://github.com/joyent/sdc-papi/blob/master/docs/index.md)
 * [Imgapi](https://github.com/joyent/sdc-imgapi/blob/master/docs/index.md)

## Usage

This library simply exposes the internal Triton API layer as cleaner Ruby function calls with a consistent interface. Rather than re-implement and re-document all the calls, a relatively small set of conventions map the function calls to the HTTP requests allowing the fantastic Joyent documentation, linked above, to be used directly.



### Configuration

When making requests, it calls APIs via their hostnames the suffix needs to be specified. This is dependent on the configuration of the triton cluster. You'll also need access to the Triton `admin` network to make the calls - you can either use this library on a host directly connected to the `admin` network or, alternatively, make calls via a SOCKS proxy.

It's possible to use the SOCKS proxy built into the `ssh` client:

    ssh -D 1234 root@<headnode ip>

    ...

    Triton.socks = '127.0.0.1:1234'

### Calling methods

Each (supported) API has a module under the `Triton` namespace - CNAPI, for example, becomes `Triton::Cnapi`. Each API function can be accessed either via the execute method using CamelCase method name from the Joyent documentation:

  > Triton::Vmapi.execute("ListVms", :fields => 'uuid')
  => [{"uuid"=>"ff64a98e-3a8a-4d90-a726-0c2fd33e378c"}, ...
{'fraction_non_alphanumeric': 0.09307427138827953, 'fraction_numerical': 0.020683171419617674, 'mean_word_length': 4.190243902439025, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7332120', 'n_tokens_mistral': 1020, 'n_tokens_neox': 924, 'n_words': 386}