1:- module(cluster, [
    2    health/3,          % +Ps, +Index, -Reply
    3    health/4,          % +Ps, +Index, +Params, -Reply
    4    pending_tasks/2,   % +Ps, +Index, -Reply
    5    pending_tasks/3,   % +Ps, +Index, +Params, -Reply
    6    state/4,           % +Ps, +Index, +Metric, -Reply
    7    state/5,           % +Ps, +Index, +Metric, +Params, -Reply
    8    stats/3,           % +Ps, +NodeID, -Reply
    9    stats/4,           % +Ps, +NodeID, +Params, -Reply
   10    reroute/3,         % +Ps, +Body, -Reply
   11    reroute/4,         % +Ps, +Params, +Body, -Reply
   12    get_settings/2,    % +Ps, -Reply
   13    get_settings/3,    % +Ps, +Params, -Reply
   14    put_settings/3,    % +Ps, +Body, -Reply
   15    put_settings/4     % +Ps, +Params, +Body, -Reply
   16]).

Cluster APIs

Manage cluster.

author
- Hongxin Liang
See also
- http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster.html */
license
- Apache License Version 2.0
   26:- use_module(transport).   27:- use_module(util).
 health(+Ps, +Index, -Reply) is semidet
 health(+Ps, +Index, +Params, -Reply) is semidet
Get a very simple status on the health of the cluster. See here.
   35health(Ps, Index, Reply) :-
   36    health(Ps, Index, _{}, Reply).
   37
   38health(Ps, Index, Params, Reply) :-
   39    make_context(['_cluster', health, Index], Context),
   40    perform_request(Ps, get, Context, Params, _, Reply).
 pending_tasks(+Ps, -Reply) is semidet
 pending_tasks(+Ps, +Params, -Reply) is semidet
The pending cluster tasks API returns a list of any cluster-level changes (e.g. create index, update mapping, allocate or fail shard) which have not yet been executed. See here.
   50pending_tasks(Ps, Reply) :-
   51    pending_tasks(Ps, _{}, Reply).
   52
   53pending_tasks(Ps, Params, Reply) :-
   54    perform_request(Ps, get, '/_cluster/pending_tasks', Params, _, Reply).
 state(+Ps, +Index, +Metric, -Reply) is semidet
 state(+Ps, +Index, +Metric, +Params, -Reply) is semidet
Get a comprehensive state information of the whole cluster. See here.
   62state(Ps, Index, Metric, Reply) :-
   63    state(Ps, Index, Metric, _{}, Reply).
   64
   65state(Ps, Index, Metric, Params, Reply) :-
   66    (   Metric = '', Index \= ''
   67    ->  Metric1 = '_all'
   68    ;   Metric1 = Metric
   69    ),
   70    make_context(['_cluster', 'state', Metric1, Index], Context),
   71    perform_request(Ps, get, Context, Params, _, Reply).
 stats(+Ps, +NodeID, -Reply) is semidet
 stats(+Ps, +NodeID, +Params, -Reply) is semidet
The Cluster Stats API allows to retrieve statistics from a cluster wide perspective. The API returns basic index metrics and information about the current nodes that form the cluster. See here.
   81stats(Ps, NodeID, Reply) :-
   82    stats(Ps, NodeID, _{}, Reply).
   83
   84stats(Ps, NodeID, Params, Reply) :-
   85    (   NodeID = ''
   86    ->  Context = '/_cluster/stats'
   87    ;   make_context(['_cluster/stats/nodes', NodeID], Context)
   88    ),
   89    perform_request(Ps, get, Context, Params, _, Reply).
 reroute(+Ps, +Body, -Reply) is semidet
 reroute(+Ps, +Params, +Body, -Reply) is semidet
Explicitly execute a cluster reroute allocation command including specific commands. See here.
   97reroute(Ps, Body, Reply) :-
   98    reroute(Ps, _{}, Body, Reply).
   99
  100reroute(Ps, Params, Body, Reply) :-
  101    perform_request(Ps, post, '/_cluster/reroute', Params, Body, _, Reply).
 get_settings(+Ps, -Reply) is semidet
 get_settings(+Ps, +Params, -Reply) is semidet
Get cluster settings. See here.
  109get_settings(Ps, Reply) :-
  110    get_settings(Ps, _{}, Reply).
  111
  112get_settings(Ps, Params, Reply) :-
  113    perform_request(Ps, get, '/_cluster/settings', Params, _, Reply).
 put_settings(+Ps, +Body, -Reply) is semidet
 put_settings(+Ps, +Params, +Body, -Reply) is semidet
Update cluster wide specific settings. See here.
  121put_settings(Ps, Body, Reply) :-
  122    put_settings(Ps, _{}, Body, Reply).
  123
  124put_settings(Ps, Params, Body, Reply) :-
  125    perform_request(Ps, put, '/_cluster/settings', Params, Body, _, Reply)