Skip to content

Commit ebe4977

Browse files
committed
[X-Pack] Adds X-Pack cat Endpoint API
1 parent 8bd57df commit ebe4977

File tree

8 files changed

+394
-0
lines changed

8 files changed

+394
-0
lines changed

elasticsearch-xpack/lib/elasticsearch/xpack.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ def transform
8787
def async_search
8888
@async_search ||= xpack.async_search
8989
end
90+
91+
def cat
92+
@cat ||= xpack.cat
93+
end
9094
end
9195
end
9296
end if defined?(Elasticsearch::Transport::Client)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Licensed to Elasticsearch B.V under one or more agreements.
2+
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
# See the LICENSE file in the project root for more information
4+
5+
module Elasticsearch
6+
module XPack
7+
module API
8+
module Cat
9+
module Actions
10+
# TODO: Description
11+
12+
#
13+
# @option arguments [String] :id The ID of the data frame analytics to fetch
14+
# @option arguments [Boolean] :allow_no_match Whether to ignore if a wildcard expression matches no configs. (This includes `_all` string or when no configs have been specified)
15+
# @option arguments [String] :bytes The unit in which to display byte values
16+
# (options: b,k,kb,m,mb,g,gb,t,tb,p,pb)
17+
18+
# @option arguments [String] :format a short version of the Accept header, e.g. json, yaml
19+
# @option arguments [List] :h Comma-separated list of column names to display
20+
# @option arguments [Boolean] :help Return help information
21+
# @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
22+
# @option arguments [String] :time The unit in which to display time values
23+
# (options: d (Days),h (Hours),m (Minutes),s (Seconds),ms (Milliseconds),micros (Microseconds),nanos (Nanoseconds))
24+
25+
# @option arguments [Boolean] :v Verbose mode. Display column headers
26+
27+
#
28+
# @see http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-dfanalytics.html
29+
#
30+
def ml_data_frame_analytics(arguments = {})
31+
arguments = arguments.clone
32+
33+
_id = arguments.delete(:id)
34+
35+
method = Elasticsearch::API::HTTP_GET
36+
path = if _id
37+
"_cat/ml/data_frame/analytics/#{Elasticsearch::API::Utils.__listify(_id)}"
38+
else
39+
"_cat/ml/data_frame/analytics"
40+
end
41+
params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
42+
43+
body = nil
44+
perform_request(method, path, params, body).body
45+
end
46+
47+
# Register this action with its valid params when the module is loaded.
48+
#
49+
# @since 6.2.0
50+
ParamsRegistry.register(:ml_data_frame_analytics, [
51+
:allow_no_match,
52+
:bytes,
53+
:format,
54+
:h,
55+
:help,
56+
:s,
57+
:time,
58+
:v
59+
].freeze)
60+
end
61+
end
62+
end
63+
end
64+
end
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Licensed to Elasticsearch B.V under one or more agreements.
2+
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
# See the LICENSE file in the project root for more information
4+
5+
module Elasticsearch
6+
module XPack
7+
module API
8+
module Cat
9+
module Actions
10+
# TODO: Description
11+
12+
#
13+
# @option arguments [String] :datafeed_id The ID of the datafeeds stats to fetch
14+
# @option arguments [Boolean] :allow_no_datafeeds Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified)
15+
# @option arguments [String] :format a short version of the Accept header, e.g. json, yaml
16+
# @option arguments [List] :h Comma-separated list of column names to display
17+
# @option arguments [Boolean] :help Return help information
18+
# @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
19+
# @option arguments [String] :time The unit in which to display time values
20+
# (options: d (Days),h (Hours),m (Minutes),s (Seconds),ms (Milliseconds),micros (Microseconds),nanos (Nanoseconds))
21+
22+
# @option arguments [Boolean] :v Verbose mode. Display column headers
23+
24+
#
25+
# @see http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-datafeeds.html
26+
#
27+
def ml_datafeeds(arguments = {})
28+
arguments = arguments.clone
29+
30+
_datafeed_id = arguments.delete(:datafeed_id)
31+
32+
method = Elasticsearch::API::HTTP_GET
33+
path = if _datafeed_id
34+
"_cat/ml/datafeeds/#{Elasticsearch::API::Utils.__listify(_datafeed_id)}"
35+
else
36+
"_cat/ml/datafeeds"
37+
end
38+
params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
39+
40+
body = nil
41+
perform_request(method, path, params, body).body
42+
end
43+
44+
# Register this action with its valid params when the module is loaded.
45+
#
46+
# @since 6.2.0
47+
ParamsRegistry.register(:ml_datafeeds, [
48+
:allow_no_datafeeds,
49+
:format,
50+
:h,
51+
:help,
52+
:s,
53+
:time,
54+
:v
55+
].freeze)
56+
end
57+
end
58+
end
59+
end
60+
end
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Licensed to Elasticsearch B.V under one or more agreements.
2+
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
# See the LICENSE file in the project root for more information
4+
5+
module Elasticsearch
6+
module XPack
7+
module API
8+
module Cat
9+
module Actions
10+
# TODO: Description
11+
12+
#
13+
# @option arguments [String] :job_id The ID of the jobs stats to fetch
14+
# @option arguments [Boolean] :allow_no_jobs Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified)
15+
# @option arguments [String] :bytes The unit in which to display byte values
16+
# (options: b,k,kb,m,mb,g,gb,t,tb,p,pb)
17+
18+
# @option arguments [String] :format a short version of the Accept header, e.g. json, yaml
19+
# @option arguments [List] :h Comma-separated list of column names to display
20+
# @option arguments [Boolean] :help Return help information
21+
# @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
22+
# @option arguments [String] :time The unit in which to display time values
23+
# (options: d (Days),h (Hours),m (Minutes),s (Seconds),ms (Milliseconds),micros (Microseconds),nanos (Nanoseconds))
24+
25+
# @option arguments [Boolean] :v Verbose mode. Display column headers
26+
27+
#
28+
# @see http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-anomaly-detectors.html
29+
#
30+
def ml_jobs(arguments = {})
31+
arguments = arguments.clone
32+
33+
_job_id = arguments.delete(:job_id)
34+
35+
method = Elasticsearch::API::HTTP_GET
36+
path = if _job_id
37+
"_cat/ml/anomaly_detectors/#{Elasticsearch::API::Utils.__listify(_job_id)}"
38+
else
39+
"_cat/ml/anomaly_detectors"
40+
end
41+
params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
42+
43+
body = nil
44+
perform_request(method, path, params, body).body
45+
end
46+
47+
# Register this action with its valid params when the module is loaded.
48+
#
49+
# @since 6.2.0
50+
ParamsRegistry.register(:ml_jobs, [
51+
:allow_no_jobs,
52+
:bytes,
53+
:format,
54+
:h,
55+
:help,
56+
:s,
57+
:time,
58+
:v
59+
].freeze)
60+
end
61+
end
62+
end
63+
end
64+
end
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Licensed to Elasticsearch B.V under one or more agreements.
2+
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
# See the LICENSE file in the project root for more information
4+
5+
module Elasticsearch
6+
module XPack
7+
module API
8+
module Cat
9+
module Actions
10+
# TODO: Description
11+
12+
#
13+
# @option arguments [String] :model_id The ID of the trained models stats to fetch
14+
# @option arguments [Boolean] :allow_no_match Whether to ignore if a wildcard expression matches no trained models. (This includes `_all` string or when no trained models have been specified)
15+
# @option arguments [Int] :from skips a number of trained models
16+
# @option arguments [Int] :size specifies a max number of trained models to get
17+
# @option arguments [String] :bytes The unit in which to display byte values
18+
# (options: b,k,kb,m,mb,g,gb,t,tb,p,pb)
19+
20+
# @option arguments [String] :format a short version of the Accept header, e.g. json, yaml
21+
# @option arguments [List] :h Comma-separated list of column names to display
22+
# @option arguments [Boolean] :help Return help information
23+
# @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
24+
# @option arguments [String] :time The unit in which to display time values
25+
# (options: d (Days),h (Hours),m (Minutes),s (Seconds),ms (Milliseconds),micros (Microseconds),nanos (Nanoseconds))
26+
27+
# @option arguments [Boolean] :v Verbose mode. Display column headers
28+
29+
#
30+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-trained-model.html
31+
#
32+
def ml_trained_models(arguments = {})
33+
arguments = arguments.clone
34+
35+
_model_id = arguments.delete(:model_id)
36+
37+
method = Elasticsearch::API::HTTP_GET
38+
path = if _model_id
39+
"_cat/ml/trained_models/#{Elasticsearch::API::Utils.__listify(_model_id)}"
40+
else
41+
"_cat/ml/trained_models"
42+
end
43+
params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
44+
45+
body = nil
46+
perform_request(method, path, params, body).body
47+
end
48+
49+
# Register this action with its valid params when the module is loaded.
50+
#
51+
# @since 6.2.0
52+
ParamsRegistry.register(:ml_trained_models, [
53+
:allow_no_match,
54+
:from,
55+
:size,
56+
:bytes,
57+
:format,
58+
:h,
59+
:help,
60+
:s,
61+
:time,
62+
:v
63+
].freeze)
64+
end
65+
end
66+
end
67+
end
68+
end
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Licensed to Elasticsearch B.V under one or more agreements.
2+
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
# See the LICENSE file in the project root for more information
4+
5+
module Elasticsearch
6+
module XPack
7+
module API
8+
module Cat
9+
module Actions
10+
module ParamsRegistry
11+
extend self
12+
13+
# A Mapping of all the actions to their list of valid params.
14+
#
15+
# @since 7.4.0
16+
PARAMS = {}
17+
18+
# Register an action with its list of valid params.
19+
#
20+
# @example Register the action.
21+
# ParamsRegistry.register(:benchmark, [ :verbose ])
22+
#
23+
# @param [ Symbol ] action The action to register.
24+
# @param [ Array[Symbol] ] valid_params The list of valid params.
25+
#
26+
# @since 7.4.0
27+
def register(action, valid_params)
28+
PARAMS[action.to_sym] = valid_params
29+
end
30+
31+
# Get the list of valid params for a given action.
32+
#
33+
# @example Get the list of valid params.
34+
# ParamsRegistry.get(:benchmark)
35+
#
36+
# @param [ Symbol ] action The action.
37+
#
38+
# @return [ Array<Symbol> ] The list of valid params for the action.
39+
#
40+
# @since 7.4.0
41+
def get(action)
42+
PARAMS.fetch(action, [])
43+
end
44+
end
45+
end
46+
end
47+
end
48+
end
49+
end
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Licensed to Elasticsearch B.V under one or more agreements.
2+
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
# See the LICENSE file in the project root for more information
4+
5+
module Elasticsearch
6+
module XPack
7+
module API
8+
module Cat
9+
module Actions
10+
# TODO: Description
11+
12+
#
13+
# @option arguments [String] :transform_id The id of the transform for which to get stats. '_all' or '*' implies all transforms
14+
# @option arguments [Int] :from skips a number of transform configs, defaults to 0
15+
# @option arguments [Int] :size specifies a max number of transforms to get, defaults to 100
16+
# @option arguments [Boolean] :allow_no_match Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified)
17+
# @option arguments [String] :format a short version of the Accept header, e.g. json, yaml
18+
# @option arguments [List] :h Comma-separated list of column names to display
19+
# @option arguments [Boolean] :help Return help information
20+
# @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
21+
# @option arguments [String] :time The unit in which to display time values
22+
# (options: d (Days),h (Hours),m (Minutes),s (Seconds),ms (Milliseconds),micros (Microseconds),nanos (Nanoseconds))
23+
24+
# @option arguments [Boolean] :v Verbose mode. Display column headers
25+
26+
#
27+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transforms.html
28+
#
29+
def transform(arguments = {})
30+
arguments = arguments.clone
31+
32+
_transform_id = arguments.delete(:transform_id)
33+
34+
method = Elasticsearch::API::HTTP_GET
35+
path = if _transform_id
36+
"_cat/transforms/#{Elasticsearch::API::Utils.__listify(_transform_id)}"
37+
else
38+
"_cat/transforms"
39+
end
40+
params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
41+
42+
body = nil
43+
perform_request(method, path, params, body).body
44+
end
45+
46+
# Register this action with its valid params when the module is loaded.
47+
#
48+
# @since 6.2.0
49+
ParamsRegistry.register(:transform, [
50+
:from,
51+
:size,
52+
:allow_no_match,
53+
:format,
54+
:h,
55+
:help,
56+
:s,
57+
:time,
58+
:v
59+
].freeze)
60+
end
61+
end
62+
end
63+
end
64+
end

0 commit comments

Comments
 (0)