1:- module(cluster, [
2 health/3, 3 health/4, 4 pending_tasks/2, 5 pending_tasks/3, 6 state/4, 7 state/5, 8 stats/3, 9 stats/4, 10 reroute/3, 11 reroute/4, 12 get_settings/2, 13 get_settings/3, 14 put_settings/3, 15 put_settings/4 16]).
26:- use_module(transport). 27:- use_module(util).
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).
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).
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).
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).
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).
109get_settings(Ps, Reply) :-
110 get_settings(Ps, _{}, Reply).
111
112get_settings(Ps, Params, Reply) :-
113 perform_request(Ps, get, '/_cluster/settings', Params, _, Reply).
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)
Cluster APIs
Manage cluster.