22 releases

new 0.9.2 Nov 4, 2024
0.9.1 May 16, 2023
0.8.1 May 10, 2023
0.5.4 Mar 15, 2023

#87 in HTTP client

Download history 56/week @ 2024-07-18 85/week @ 2024-07-25 40/week @ 2024-08-01 37/week @ 2024-08-08 37/week @ 2024-08-15 17/week @ 2024-08-22 12/week @ 2024-08-29 34/week @ 2024-09-05 62/week @ 2024-09-12 89/week @ 2024-09-19 75/week @ 2024-09-26 42/week @ 2024-10-03 30/week @ 2024-10-10 58/week @ 2024-10-17 65/week @ 2024-10-24 158/week @ 2024-10-31

315 downloads per month
Used in nomad_events_logger

MIT license

230KB
5K SLoC

Nomad Client

License Lines of code Crates.io Crates.io

Nomad HTTP API Client

Table of contents

Overview

HTTP API Version : v1.5.x

Quick start

Install the package over cli

cargo add nomad-client-rs

or add the following to your 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(),
  token: None,
  ..Config::default()
};

let client = NomadClient::new(client_config);

Implemented API Endpoints

Class Method HTTP Request
allocation allocation_restart POST /client/allocation/{alloc_id}/restart
acl acl_tokens_list GET /acl/tokens
acl acl_token_create POST /acl/token
acl acl_token_update POST /acl/token/{accessor_id}
acl acl_token_read GET /acl/token/{accessor_id}
acl acl_token_read_self GET /acl/token/self
acl acl_token_delete DELETE /acl/token/{accessor_id}
client client_list_files GET /client/fs/ls/{alloc_id}?path={file_path}
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}
client client_read_metadata GET /client/metadata
client client_update_metadata POST /client/metadata
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
job job_list_allocations GET /job/{job_name}/allocations
job job_delete DELETE /job/{job_name}
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
variable variables_list GET /vars
variable variable_get GET /var/{var_path}
variable variable_create PUT /var/{var_path}
variable variable_delete DELETE /var/{var_path}
service service_list GET /services
service variable_get GET /services/{service_name}

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
NOMAD_SECRET_TOKEN
NOMAD_TLS_ALLOW_INSECURE false
NOMAD_MTLS_CERT_PATH
NOMAD_MTLS_KEY_PATH

Authentiction

MTLS

NomadClient supports mtls authentication using .pem files only. To use mtls authentication simply configure mtls field in Config struct.

let client_config = Config {
  mtls: Some(MTLSConfig::new("path/to/client.pem", "path/to/client-key.pem"));
  ..Config::default()
};

Dependencies

~7–19MB
~255K SLoC