Nomad HTTP API Client
HTTP API Version : v1.5.x
Install the package over cli
bash
cargo add nomad-client-rs
or add the following to your Cargo.toml
toml
[dependencies]
nomad-client-rs = "x.x.x"
Default nomad client uses environment variables / default values
rust
let client = NomadClient::default();
Nomad client with custom config
```rust let clientconfig = Config { baseurl: "http://example".into(), port: 1234, api_version: "v1".into(), token: None, ..Config::default() };
let client = NomadClient::new(client_config); ```
| Class | Method | HTTP Request |
|------------|----------------------------|-------------------------------------------------|
| allocation | allocationrestart | POST /client/allocation/{allocid}/restart |
| client | clientlistfiles | GET /client/fs/ls/{allocid}?path={filepath} |
| client | clientgetfile | GET /client/fs/cat/{allocid}?path={filepath} |
| client | clientgetfileinfo | GET /client/fs/stat/{allocid}?path={filepath} |
| client | clientreadmetadata | GET /client/metadata |
| client | clientupdatemetadata | POST /client/metadata |
| deployment | deploymentlist | GET /deployments |
| deployment | deploymentget | GET /deployments/{id} |
| deployment | deploymentallocationlist | GET /deployment/allocations/{id} |
| deployment | deploymentfail | POST /deployment/fail/{id} |
| event | eventssubscribe | GET /event/stream |
| job | jobdispatch | POST /job/{jobname}/dispatch |
| job | jobparse | POST /job/parse |
| job | jobcreate | POST /jobs |
| job | joblistallocations | GET /job/{jobname}/allocations |
| job | jobdelete | DELETE /job/{jobname} |
| namespace | namespacelist | GET /namespaces |
| namespace | namespaceget | GET /namespace/{namespace} |
| namespace | namespacecreate | POST /namespace |
| namespace | namespacedelete | DELETE /namespace/{namespace} |
| status | statusgetpeers | GET /status/peers |
| status | statusgetleader | GET /status/leader |
| variable | variableslist | GET /vars |
| variable | variableget | GET /var/{varpath} |
| variable | variablecreate | PUT /var/{varpath} |
| variable | variabledelete | DELETE /var/{var_path} |
NomadClient can be configured by env variables.
If env variable is not available it will use specified default value.
| Variable | Default | |--------------------------|------------------| | NOMADBASEURL | http://localhost | | NOMADPORT | 4646 | | NOMADAPIVERSION | v1 | | NOMADSECRETTOKEN | | | NOMADTLSALLOWINSECURE | false | | NOMADMTLSCERTPATH | | | NOMADMTLSKEYPATH | |
NomadClient supports mtls authentication using .pem
files only.
To use mtls authentication simply configure mtls
field in Config
struct.
rust
let client_config = Config {
mtls: Some(MTLSConfig::new("path/to/client.pem", "path/to/client-key.pem"));
..Config::default()
};