Skip to content

Commit 35ee41b

Browse files
committed
[API] Adds ilm.migrate_to_data_tiers
1 parent 27bd6f6 commit 35ee41b

File tree

3 files changed

+90
-1
lines changed

3 files changed

+90
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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 IndexLifecycleManagement
22+
module Actions
23+
# Migrates the indices and ILM policies away from custom node attribute allocation routing to data tiers routing
24+
#
25+
# @option arguments [Boolean] :dry_run If set to true it will simulate the migration, providing a way to retrieve the ILM policies and indices that need to be migrated. The default is false
26+
# @option arguments [Hash] :headers Custom HTTP headers
27+
# @option arguments [Hash] :body Optionally specify a legacy index template name to delete and optionally specify a node attribute name used for index shard routing (defaults to "data")
28+
#
29+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.14/ilm-migrate-to-data-tiers.html
30+
#
31+
def migrate_to_data_tiers(arguments = {})
32+
headers = arguments.delete(:headers) || {}
33+
34+
arguments = arguments.clone
35+
36+
method = Elasticsearch::API::HTTP_POST
37+
path = "_ilm/migrate_to_data_tiers"
38+
params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
39+
40+
body = arguments[:body]
41+
perform_request(method, path, params, body, headers).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(:migrate_to_data_tiers, [
48+
:dry_run
49+
].freeze)
50+
end
51+
end
52+
end
53+
end
54+
end

elasticsearch-xpack/lib/elasticsearch/xpack/api/namespace/index_lifecycle_management.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class IndexLifecycleManagementClient
2828
def ilm
2929
@ilm ||= IndexLifecycleManagementClient.new(self)
3030
end
31-
3231
end
3332
end
3433
end
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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.index_lifecycle_management#migrate_to_data_tiers' do
21+
let(:expected_args) do
22+
[
23+
'POST',
24+
'_ilm/migrate_to_data_tiers',
25+
{},
26+
nil,
27+
{}
28+
]
29+
end
30+
31+
let(:index) { 'foo' }
32+
33+
it 'performs the request' do
34+
expect(client_double.ilm.migrate_to_data_tiers).to eq({})
35+
end
36+
end

0 commit comments

Comments
 (0)