Skip to content

Commit 5ba4e73

Browse files
committed
[API] Adds indices APIs: cancel_migrate_reindex, create_form, get_migrate_reindex_status, migrate_reindex
1 parent 5c4d50b commit 5ba4e73

File tree

8 files changed

+378
-0
lines changed

8 files changed

+378
-0
lines changed
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 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+
# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80
19+
# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec
20+
#
21+
module Elasticsearch
22+
module API
23+
module Indices
24+
module Actions
25+
# Cancel a migration reindex operation
26+
#
27+
# @option arguments [String] :index The index or data stream name
28+
# @option arguments [Hash] :headers Custom HTTP headers
29+
#
30+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/8.19/migrate-data-stream.html
31+
#
32+
def cancel_migrate_reindex(arguments = {})
33+
request_opts = { endpoint: arguments[:endpoint] || 'indices.cancel_migrate_reindex' }
34+
35+
defined_params = [:index].each_with_object({}) do |variable, set_variables|
36+
set_variables[variable] = arguments[variable] if arguments.key?(variable)
37+
end
38+
request_opts[:defined_params] = defined_params unless defined_params.empty?
39+
40+
raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
41+
42+
arguments = arguments.clone
43+
headers = arguments.delete(:headers) || {}
44+
45+
body = nil
46+
47+
_index = arguments.delete(:index)
48+
49+
method = Elasticsearch::API::HTTP_POST
50+
path = "_migration/reindex/#{Utils.__listify(_index)}/_cancel"
51+
params = {}
52+
53+
Elasticsearch::API::Response.new(
54+
perform_request(method, path, params, body, headers, request_opts)
55+
)
56+
end
57+
end
58+
end
59+
end
60+
end
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80
19+
# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec
20+
#
21+
module Elasticsearch
22+
module API
23+
module Indices
24+
module Actions
25+
# Create an index from a source index
26+
#
27+
# @option arguments [String] :source The source index name
28+
# @option arguments [String] :dest The destination index name
29+
# @option arguments [Hash] :headers Custom HTTP headers
30+
# @option arguments [Hash] :body The body contains the fields `mappings_override`, `settings_override`, and `remove_index_blocks`.
31+
#
32+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/8.19/migrate-data-stream.html
33+
#
34+
def create_from(arguments = {})
35+
request_opts = { endpoint: arguments[:endpoint] || 'indices.create_from' }
36+
37+
defined_params = %i[source dest].each_with_object({}) do |variable, set_variables|
38+
set_variables[variable] = arguments[variable] if arguments.key?(variable)
39+
end
40+
request_opts[:defined_params] = defined_params unless defined_params.empty?
41+
42+
raise ArgumentError, "Required argument 'source' missing" unless arguments[:source]
43+
raise ArgumentError, "Required argument 'dest' missing" unless arguments[:dest]
44+
45+
arguments = arguments.clone
46+
headers = arguments.delete(:headers) || {}
47+
48+
body = arguments.delete(:body)
49+
50+
_source = arguments.delete(:source)
51+
52+
_dest = arguments.delete(:dest)
53+
54+
method = Elasticsearch::API::HTTP_PUT
55+
path = "_create_from/#{Utils.__listify(_source)}/#{Utils.__listify(_dest)}"
56+
params = {}
57+
58+
Elasticsearch::API::Response.new(
59+
perform_request(method, path, params, body, headers, request_opts)
60+
)
61+
end
62+
end
63+
end
64+
end
65+
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 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+
# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80
19+
# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec
20+
#
21+
module Elasticsearch
22+
module API
23+
module Indices
24+
module Actions
25+
# Get the migration reindexing status
26+
#
27+
# @option arguments [String] :index The index or data stream name
28+
# @option arguments [Hash] :headers Custom HTTP headers
29+
#
30+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/8.19/migrate-data-stream.html
31+
#
32+
def get_migrate_reindex_status(arguments = {})
33+
request_opts = { endpoint: arguments[:endpoint] || 'indices.get_migrate_reindex_status' }
34+
35+
defined_params = [:index].each_with_object({}) do |variable, set_variables|
36+
set_variables[variable] = arguments[variable] if arguments.key?(variable)
37+
end
38+
request_opts[:defined_params] = defined_params unless defined_params.empty?
39+
40+
raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
41+
42+
arguments = arguments.clone
43+
headers = arguments.delete(:headers) || {}
44+
45+
body = nil
46+
47+
_index = arguments.delete(:index)
48+
49+
method = Elasticsearch::API::HTTP_GET
50+
path = "_migration/reindex/#{Utils.__listify(_index)}/_status"
51+
params = {}
52+
53+
Elasticsearch::API::Response.new(
54+
perform_request(method, path, params, body, headers, request_opts)
55+
)
56+
end
57+
end
58+
end
59+
end
60+
end
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80
19+
# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec
20+
#
21+
module Elasticsearch
22+
module API
23+
module Indices
24+
module Actions
25+
# Reindex legacy backing indices
26+
#
27+
# @option arguments [Hash] :headers Custom HTTP headers
28+
# @option arguments [Hash] :body The body contains the fields `mode` and `source.index, where the only mode currently supported is `upgrade`, and the `source.index` must be a data stream name (*Required*)
29+
#
30+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/8.19/migrate-data-stream.html
31+
#
32+
def migrate_reindex(arguments = {})
33+
request_opts = { endpoint: arguments[:endpoint] || 'indices.migrate_reindex' }
34+
35+
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
36+
37+
arguments = arguments.clone
38+
headers = arguments.delete(:headers) || {}
39+
40+
body = arguments.delete(:body)
41+
42+
method = Elasticsearch::API::HTTP_POST
43+
path = '_migration/reindex'
44+
params = {}
45+
46+
Elasticsearch::API::Response.new(
47+
perform_request(method, path, params, body, headers, request_opts)
48+
)
49+
end
50+
end
51+
end
52+
end
53+
end
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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.indices#cancel_migrate_reindex' do
21+
let(:expected_args) do
22+
[
23+
'POST',
24+
'_migration/reindex/foo/_cancel',
25+
{},
26+
nil,
27+
{},
28+
{ defined_params: { index: 'foo' }, endpoint: 'indices.cancel_migrate_reindex' }
29+
]
30+
end
31+
32+
it 'performs the request' do
33+
expect(client_double.indices.cancel_migrate_reindex(index: 'foo')).to be_a Elasticsearch::API::Response
34+
end
35+
end
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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.indices#create_from' do
21+
let(:expected_args) do
22+
[
23+
'PUT',
24+
'_create_from/foo/bar',
25+
{},
26+
nil,
27+
{},
28+
{ defined_params: { source: 'foo', dest: 'bar' }, endpoint: 'indices.create_from' }
29+
]
30+
end
31+
32+
it 'performs the request' do
33+
expect(client_double.indices.create_from(source: 'foo', dest: 'bar')).to be_a Elasticsearch::API::Response
34+
end
35+
end
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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.indices#get_migrate_reindex_status' do
21+
let(:expected_args) do
22+
[
23+
'GET',
24+
'_migration/reindex/foo/_status',
25+
{},
26+
nil,
27+
{},
28+
{ defined_params: { index: 'foo' }, endpoint: 'indices.get_migrate_reindex_status' }
29+
]
30+
end
31+
32+
it 'performs the request' do
33+
expect(client_double.indices.get_migrate_reindex_status(index: 'foo')).to be_a Elasticsearch::API::Response
34+
end
35+
end
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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.indices#migrate_reindex' do
21+
let(:expected_args) do
22+
[
23+
'POST',
24+
'_migration/reindex',
25+
{},
26+
{},
27+
{},
28+
{ endpoint: 'indices.migrate_reindex' }
29+
]
30+
end
31+
32+
it 'performs the request' do
33+
expect(client_double.indices.migrate_reindex(body: {})).to be_a Elasticsearch::API::Response
34+
end
35+
end

0 commit comments

Comments
 (0)