Skip to content

Commit 7f47962

Browse files
committed
[API] Adds experimental endpoint fleet.global_checkpoints
1 parent af1a1f9 commit 7f47962

File tree

6 files changed

+211
-1
lines changed

6 files changed

+211
-1
lines changed

elasticsearch-api/utils/thor/generator/files_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def self.files(api)
4646

4747
XPACK_ENDPOINTS = [
4848
'autoscaling', 'cross_cluster_replication', 'ccr', 'data_frame_transform_deprecated',
49-
'enrich', 'eql', 'ilm', 'logstash', 'migration', 'watcher', 'slm'
49+
'enrich', 'eql', 'fleet', 'ilm', 'logstash', 'migration', 'watcher', 'slm'
5050
]
5151
XPACK_ENDPOINTS_REGEXP = /data_stream|ml_|reload_search_analyzers|transform/
5252

elasticsearch-xpack/lib/elasticsearch/xpack.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ def text_structure
160160
def logstash
161161
@logstash ||= xpack.logstash
162162
end
163+
164+
def fleet
165+
@fleet ||= xpack.fleet
166+
end
163167
end
164168
end
165169
end if defined?(Elasticsearch::Transport::Client)
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Licensed to Elasticsearch B.V. under one or more contributor
2+
# license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright
4+
# ownership. Elasticsearch B.V. licenses this file to you under
5+
# the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
module Elasticsearch
19+
module XPack
20+
module API
21+
module Fleet
22+
module Actions
23+
# Returns the current global checkpoints for an index. This API is design for internal use by the fleet server project.
24+
# This functionality is Experimental and may be changed or removed
25+
# completely in a future release. Elastic will take a best effort approach
26+
# to fix any issues, but experimental features are not subject to the
27+
# support SLA of official GA features.
28+
#
29+
# @option arguments [String] :index The name of the index.
30+
# @option arguments [Boolean] :wait_for_advance Whether to wait for the global checkpoint to advance past the specified current checkpoints
31+
# @option arguments [List] :checkpoints Comma separated list of checkpoints
32+
# @option arguments [Time] :timeout Timeout to wait for global checkpoint to advance
33+
# @option arguments [Hash] :headers Custom HTTP headers
34+
#
35+
# @see [TODO]
36+
#
37+
def global_checkpoints(arguments = {})
38+
raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
39+
40+
headers = arguments.delete(:headers) || {}
41+
42+
arguments = arguments.clone
43+
44+
_index = arguments.delete(:index)
45+
46+
method = Elasticsearch::API::HTTP_GET
47+
path = "#{Elasticsearch::API::Utils.__listify(_index)}/_fleet/global_checkpoints"
48+
params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
49+
50+
body = nil
51+
perform_request(method, path, params, body, headers).body
52+
end
53+
54+
# Register this action with its valid params when the module is loaded.
55+
#
56+
# @since 6.2.0
57+
ParamsRegistry.register(:global_checkpoints, [
58+
:wait_for_advance,
59+
:checkpoints,
60+
:timeout
61+
].freeze)
62+
end
63+
end
64+
end
65+
end
66+
end
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Licensed to Elasticsearch B.V. under one or more contributor
2+
# license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright
4+
# ownership. Elasticsearch B.V. licenses this file to you under
5+
# the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
module Elasticsearch
19+
module XPack
20+
module API
21+
module Fleet
22+
module Actions
23+
module ParamsRegistry
24+
extend self
25+
26+
# A Mapping of all the actions to their list of valid params.
27+
#
28+
# @since 7.4.0
29+
PARAMS = {}
30+
31+
# Register an action with its list of valid params.
32+
#
33+
# @example Register the action.
34+
# ParamsRegistry.register(:benchmark, [ :verbose ])
35+
#
36+
# @param [ Symbol ] action The action to register.
37+
# @param [ Array[Symbol] ] valid_params The list of valid params.
38+
#
39+
# @since 7.4.0
40+
def register(action, valid_params)
41+
PARAMS[action.to_sym] = valid_params
42+
end
43+
44+
# Get the list of valid params for a given action.
45+
#
46+
# @example Get the list of valid params.
47+
# ParamsRegistry.get(:benchmark)
48+
#
49+
# @param [ Symbol ] action The action.
50+
#
51+
# @return [ Array<Symbol> ] The list of valid params for the action.
52+
#
53+
# @since 7.4.0
54+
def get(action)
55+
PARAMS.fetch(action, [])
56+
end
57+
end
58+
end
59+
end
60+
end
61+
end
62+
end
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Licensed to Elasticsearch B.V. under one or more contributor
2+
# license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright
4+
# ownership. Elasticsearch B.V. licenses this file to you under
5+
# the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
module Elasticsearch
19+
module XPack
20+
module API
21+
module Fleet
22+
module Actions; end
23+
24+
class FleetClient
25+
include Elasticsearch::API::Common::Client, Elasticsearch::API::Common::Client::Base, Fleet::Actions
26+
end
27+
28+
def fleet
29+
@fleet ||= FleetClient.new(self)
30+
end
31+
end
32+
end
33+
end
34+
end
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Licensed to Elasticsearch B.V. under one or more contributor
2+
# license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright
4+
# ownership. Elasticsearch B.V. licenses this file to you under
5+
# the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
require 'spec_helper'
19+
20+
describe 'client#fleet.global_checkpoints' do
21+
let(:expected_args) do
22+
[
23+
'GET',
24+
'foo/_fleet/global_checkpoints',
25+
{},
26+
nil,
27+
{}
28+
]
29+
end
30+
31+
it 'performs the request' do
32+
expect(client_double.fleet.global_checkpoints(index: 'foo')).to eq({})
33+
end
34+
35+
let(:client) do
36+
Class.new { include Elasticsearch::XPack::API }.new
37+
end
38+
39+
it 'requires the :index argument' do
40+
expect {
41+
client.fleet.global_checkpoints
42+
}.to raise_exception(ArgumentError)
43+
end
44+
end

0 commit comments

Comments
 (0)