Skip to content

Commit f49bb6d

Browse files
committed
[API] Adds migrate endpoints from elasticsearch-specification
1 parent 0bfdbc1 commit f49bb6d

File tree

5 files changed

+352
-0
lines changed

5 files changed

+352
-0
lines changed
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+
# Auto generated from commit dcb1c1df18a84a0182caa631b4577d89a4602cfe
19+
# @see https://github.com/elastic/elasticsearch-specification
20+
#
21+
module Elasticsearch
22+
module API
23+
module Indices
24+
module Actions
25+
# Cancel a migration reindex operation.
26+
# Cancel a migration reindex attempt for a data stream or index.
27+
# This functionality is Experimental and may be changed or removed
28+
# completely in a future release. Elastic will take a best effort approach
29+
# to fix any issues, but experimental features are not subject to the
30+
# support SLA of official GA features.
31+
#
32+
# @option arguments [String, Array] :index The index or data stream name (*Required*)
33+
# @option arguments [Hash] :headers Custom HTTP headers
34+
#
35+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/migrate-data-stream.html
36+
#
37+
def cancel_migrate_reindex(arguments = {})
38+
request_opts = { endpoint: arguments[:endpoint] || 'indices.cancel_migrate_reindex' }
39+
40+
defined_params = [:index].inject({}) do |set_variables, variable|
41+
set_variables[variable] = arguments[variable] if arguments.key?(variable)
42+
set_variables
43+
end
44+
request_opts[:defined_params] = defined_params unless defined_params.empty?
45+
46+
raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
47+
48+
arguments = arguments.clone
49+
headers = arguments.delete(:headers) || {}
50+
51+
body = nil
52+
53+
_index = arguments.delete(:index)
54+
55+
method = Elasticsearch::API::HTTP_POST
56+
path = "_migration/reindex/#{Utils.__listify(_index)}/_cancel"
57+
params = {}
58+
59+
Elasticsearch::API::Response.new(
60+
perform_request(method, path, params, body, headers, request_opts)
61+
)
62+
end
63+
end
64+
end
65+
end
66+
end
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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 commit dcb1c1df18a84a0182caa631b4577d89a4602cfe
19+
# @see https://github.com/elastic/elasticsearch-specification
20+
#
21+
module Elasticsearch
22+
module API
23+
module Indices
24+
module Actions
25+
# Create an index from a source index.
26+
# Copy the mappings and settings from the source index to a destination index while allowing request settings and mappings to override the source values.
27+
# This functionality is Experimental and may be changed or removed
28+
# completely in a future release. Elastic will take a best effort approach
29+
# to fix any issues, but experimental features are not subject to the
30+
# support SLA of official GA features.
31+
#
32+
# @option arguments [String] :source The source index or data stream name (*Required*)
33+
# @option arguments [String] :dest The destination index or data stream name (*Required*)
34+
# @option arguments [Hash] :headers Custom HTTP headers
35+
# @option arguments [Hash] :body create_from
36+
#
37+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/migrate-data-stream.html
38+
#
39+
def create_from(arguments = {})
40+
request_opts = { endpoint: arguments[:endpoint] || 'indices.create_from' }
41+
42+
defined_params = [:source, :dest].inject({}) do |set_variables, variable|
43+
set_variables[variable] = arguments[variable] if arguments.key?(variable)
44+
set_variables
45+
end
46+
request_opts[:defined_params] = defined_params unless defined_params.empty?
47+
48+
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
49+
raise ArgumentError, "Required argument 'source' missing" unless arguments[:source]
50+
raise ArgumentError, "Required argument 'dest' missing" unless arguments[:dest]
51+
52+
arguments = arguments.clone
53+
headers = arguments.delete(:headers) || {}
54+
55+
body = arguments.delete(:body)
56+
57+
_source = arguments.delete(:source)
58+
59+
_dest = arguments.delete(:dest)
60+
61+
method = Elasticsearch::API::HTTP_PUT
62+
path = "_create_from/#{Utils.__listify(_source)}/#{Utils.__listify(_dest)}"
63+
params = {}
64+
65+
Elasticsearch::API::Response.new(
66+
perform_request(method, path, params, body, headers, request_opts)
67+
)
68+
end
69+
end
70+
end
71+
end
72+
end
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+
# Auto generated from commit dcb1c1df18a84a0182caa631b4577d89a4602cfe
19+
# @see https://github.com/elastic/elasticsearch-specification
20+
#
21+
module Elasticsearch
22+
module API
23+
module Indices
24+
module Actions
25+
# Get the migration reindexing status.
26+
# Get the status of a migration reindex attempt for a data stream or index.
27+
# This functionality is Experimental and may be changed or removed
28+
# completely in a future release. Elastic will take a best effort approach
29+
# to fix any issues, but experimental features are not subject to the
30+
# support SLA of official GA features.
31+
#
32+
# @option arguments [String, Array] :index The index or data stream name. (*Required*)
33+
# @option arguments [Hash] :headers Custom HTTP headers
34+
#
35+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/migrate-data-stream.html
36+
#
37+
def get_migrate_reindex_status(arguments = {})
38+
request_opts = { endpoint: arguments[:endpoint] || 'indices.get_migrate_reindex_status' }
39+
40+
defined_params = [:index].inject({}) do |set_variables, variable|
41+
set_variables[variable] = arguments[variable] if arguments.key?(variable)
42+
set_variables
43+
end
44+
request_opts[:defined_params] = defined_params unless defined_params.empty?
45+
46+
raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
47+
48+
arguments = arguments.clone
49+
headers = arguments.delete(:headers) || {}
50+
51+
body = nil
52+
53+
_index = arguments.delete(:index)
54+
55+
method = Elasticsearch::API::HTTP_GET
56+
path = "_migration/reindex/#{Utils.__listify(_index)}/_status"
57+
params = {}
58+
59+
Elasticsearch::API::Response.new(
60+
perform_request(method, path, params, body, headers, request_opts)
61+
)
62+
end
63+
end
64+
end
65+
end
66+
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 commit dcb1c1df18a84a0182caa631b4577d89a4602cfe
19+
# @see https://github.com/elastic/elasticsearch-specification
20+
#
21+
module Elasticsearch
22+
module API
23+
module Indices
24+
module Actions
25+
# Reindex legacy backing indices.
26+
# Reindex all legacy backing indices for a data stream.
27+
# This operation occurs in a persistent task.
28+
# The persistent task ID is returned immediately and the reindexing work is completed in that task.
29+
# This functionality is Experimental and may be changed or removed
30+
# completely in a future release. Elastic will take a best effort approach
31+
# to fix any issues, but experimental features are not subject to the
32+
# support SLA of official GA features.
33+
#
34+
# @option arguments [Hash] :headers Custom HTTP headers
35+
# @option arguments [Hash] :body reindex
36+
#
37+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/migrate-data-stream.html
38+
#
39+
def migrate_reindex(arguments = {})
40+
request_opts = { endpoint: arguments[:endpoint] || 'indices.migrate_reindex' }
41+
42+
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
43+
44+
arguments = arguments.clone
45+
headers = arguments.delete(:headers) || {}
46+
47+
body = arguments.delete(:body)
48+
49+
method = Elasticsearch::API::HTTP_POST
50+
path = "_migration/reindex"
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: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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' do
21+
context 'migrate_reindex' do
22+
let(:expected_args) do
23+
[
24+
'POST',
25+
'_migration/reindex',
26+
{},
27+
{},
28+
{},
29+
{ endpoint: 'indices.migrate_reindex' }
30+
]
31+
end
32+
33+
it 'performs the request' do
34+
expect(client_double.indices.migrate_reindex(body: {})).to be_a Elasticsearch::API::Response
35+
end
36+
end
37+
38+
context 'get_migrate_reindex_status' do
39+
let(:expected_args) do
40+
[
41+
'GET',
42+
'_migration/reindex/foo/_status',
43+
{},
44+
nil,
45+
{},
46+
{ endpoint: 'indices.get_migrate_reindex_status', defined_params: { index: 'foo' } }
47+
]
48+
end
49+
50+
it 'performs the request' do
51+
expect(client_double.indices.get_migrate_reindex_status(index: 'foo')).to be_a Elasticsearch::API::Response
52+
end
53+
end
54+
55+
context 'cancel_migrate_reindex' do
56+
let(:expected_args) do
57+
[
58+
'POST',
59+
'_migration/reindex/foo/_cancel',
60+
{},
61+
nil,
62+
{},
63+
{ endpoint: 'indices.cancel_migrate_reindex', defined_params: { index: 'foo' } }
64+
]
65+
end
66+
67+
it 'performs the request' do
68+
expect(client_double.indices.cancel_migrate_reindex(index: 'foo')).to be_a Elasticsearch::API::Response
69+
end
70+
end
71+
72+
context 'create_from' do
73+
let(:expected_args) do
74+
[
75+
'PUT',
76+
'_create_from/foo/bar',
77+
{},
78+
{},
79+
{},
80+
{ endpoint: 'indices.create_from', defined_params: { source: 'foo', dest: 'bar' } }
81+
]
82+
end
83+
84+
it 'performs the request' do
85+
expect(client_double.indices.create_from(body: {}, source: 'foo', dest: 'bar')).to be_a Elasticsearch::API::Response
86+
end
87+
end
88+
end

0 commit comments

Comments
 (0)