nomad-client-rs 0.2.1

A HashiCorp Nomad's HTTP API client
Documentation

Nomad Client

License Lines of code Crates.io Crates.io

Nomad HTTP API Client

Table of contents

Overview

HTTP API Version : v1.4.x

Quick start

  • cargo add nomad-client-rs
  • Put the package under your project folder and add the following to Cargo.toml:
    [dependencies]
    nomad-client-rs = "x.x.x"
    

Usage

Default nomad client uses environment variables / default values

let client = NomadClient::default();

Nomad client with custom config

let client_config = Config {
    base_url: "http://example".into(),
    port: 1234,
    api_version: "v1".into(),
};

let client = NomadClient::new(client_config);

Implemented API Endpoints

Class Method HTTP Request
client client_list_files GET /client/fs/ls/{alloc_id}
client client_get_file GET /client/fs/cat/{alloc_id}?path={file_path}
client client_get_file_info GET /client/fs/stat/{alloc_id}?path={file_path}
deployment deployment_list GET /deployments
deployment deployment_get GET /deployments/{id}
deployment deployment_allocation_list GET /deployment/allocations/{id}
deployment deployment_fail POST /deployment/fail/{id}
event events_subscribe GET /event/stream
job job_dispatch POST /job/{job_name}/dispatch
job job_parse POST /job/parse
job job_create POST /jobs
namespace namespace_list GET /namespaces
namespace namespace_get GET /namespace/{namespace}
namespace namespace_create POST /namespace
namespace namespace_delete DELETE /namespace/{namespace}
status status_get_peers GET /status/peers
status status_get_leader GET /status/leader

Environment

Variables

NomadClient can be configured by env variables. If env variable is not available it will use specified default value.

Variable Default
NOMAD_BASE_URL http://localhost
NOMAD_PORT 4646
NOMAD_API_VERSION v1

ToDo's

  • authentication
  • documentation
  • more tests