netapi modules

# `netapi` modules

netapi modules provide API access to Salt functionality over the network.

The included netapi modules support REST (over HTTP and WSGI) and WebSockets.

Modules expose functions from the `NetapiClient` and give access to the same functionality as the Salt commandline tools (salt, salt-run, etc).

## Client interfaces

Salt's client interfaces provide the ability to execute functions from execution, runnner, and wheel modules.

The client interfaces available via netapi modules are defined in the `NetapiClient`, which is a limited version of the Python API.

The client interfaces accept a dictionary with values for the function and its arguments.

Available interfaces:

- local - run execution modules on minions

- local_subset - run execution modules on a subset of minions

- runner - run runner modules on master

- ssh - run salt-ssh commands

- wheel - run wheel modules

The local, runner, and wheel clients also have async variants to run modules asynchronously.

## Configuration

The `netapi_enable_clients` list in the master config sets which client interfaces are available. It is recommended to only enable the client interfaces required to complete the tasks needed to reduce the amount of Salt functionality exposed via the netapi. See the netapi_enable clients documentation.

- Enabling netapi client interfaces
  - Steps to enable netapi client interfaces
    - Select client interfaces to enable
    - Update Salt master config
    - Restart salt-master and salt-api
    - Verify required functionality

Individual netapi modules can be enabled by adding the module configuration section to the master config. The required configuration and dependencies are documented for each module.

The salt-api daemon manages netapi modules instances and must be started to enable the configured netapi modules. It is possible to run multiple netapi modules and multiple instances of each module.

`netapi_enable_clients`

Prior to Salt's 3006.0 release all client interfaces were enabled and it was not possible to disable clients individually.

## Developing modules

Developing custom netapi modules for new transports or protocols is documented in the Writing netapi modules and NetapiClient documentation.

- Writing netapi modules
  - Configuration
  - The `__virtual__` function
  - The `start` function
  - Multiple instances
  - Inline documentation
  - Loader “magic” methods
- NetapiClient
  - `NetapiClient`
    - `NetapiClient.local()`
    - `NetapiClient.local_async()`
    - `NetapiClient.local_subset()`
    - `NetapiClient.run()`
    - `NetapiClient.runner()`
    - `NetapiClient.runner_async()`
    - `NetapiClient.ssh()`
    - `NetapiClient.wheel()`
    - `NetapiClient.wheel_async()`