Skip to content

Commit bf04062

Browse files
committed
[API] Adds indices data lifecycle APIs
- indices.delete_data_lifecycle - indices.get_data_lifecycle - indices.put_data_lifecycle
1 parent 2907f3a commit bf04062

File tree

6 files changed

+306
-0
lines changed

6 files changed

+306
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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+
# Deletes the data lifecycle of the selected data streams.
26+
#
27+
# @option arguments [List] :name A comma-separated list of data streams of which the data lifecycle will be deleted; use `*` to get all data streams
28+
# @option arguments [String] :expand_wildcards Whether wildcard expressions should get expanded to open or closed indices (default: open) (options: open, closed, hidden, none, all)
29+
# @option arguments [Time] :timeout Explicit timestamp for the document
30+
# @option arguments [Time] :master_timeout Specify timeout for connection to master
31+
# @option arguments [Hash] :headers Custom HTTP headers
32+
#
33+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/dlm-delete-lifecycle.html
34+
#
35+
def delete_data_lifecycle(arguments = {})
36+
arguments = arguments.clone
37+
headers = arguments.delete(:headers) || {}
38+
39+
body = nil
40+
41+
_name = arguments.delete(:name)
42+
43+
method = Elasticsearch::API::HTTP_DELETE
44+
path = if _name
45+
"_data_stream/#{Utils.__listify(_name)}/_lifecycle"
46+
else
47+
"_data_stream/_lifecycle"
48+
end
49+
params = Utils.process_params(arguments)
50+
51+
Elasticsearch::API::Response.new(
52+
perform_request(method, path, params, body, headers)
53+
)
54+
end
55+
end
56+
end
57+
end
58+
end
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
# Returns the data lifecycle of the selected data streams.
26+
#
27+
# @option arguments [List] :name A comma-separated list of data streams to get; use `*` to get all data streams
28+
# @option arguments [String] :expand_wildcards Whether wildcard expressions should get expanded to open or closed indices (default: open) (options: open, closed, hidden, none, all)
29+
# @option arguments [Boolean] :include_defaults Return all relevant default configurations for the data stream (default: false)
30+
# @option arguments [Hash] :headers Custom HTTP headers
31+
#
32+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/dlm-get-lifecycle.html
33+
#
34+
def get_data_lifecycle(arguments = {})
35+
arguments = arguments.clone
36+
headers = arguments.delete(:headers) || {}
37+
38+
body = nil
39+
40+
_name = arguments.delete(:name)
41+
42+
method = Elasticsearch::API::HTTP_GET
43+
path = if _name
44+
"_data_stream/#{Utils.__listify(_name)}/_lifecycle"
45+
else
46+
"_data_stream/_lifecycle"
47+
end
48+
params = Utils.process_params(arguments)
49+
50+
Elasticsearch::API::Response.new(
51+
perform_request(method, path, params, body, headers)
52+
)
53+
end
54+
end
55+
end
56+
end
57+
end
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+
# Updates the data lifecycle of the selected data streams.
26+
#
27+
# @option arguments [List] :name A comma-separated list of data streams whose lifecycle will be updated; use `*` to set the lifecycle to all data streams
28+
# @option arguments [String] :expand_wildcards Whether wildcard expressions should get expanded to open or closed indices (default: open) (options: open, closed, hidden, none, all)
29+
# @option arguments [Time] :timeout Explicit timestamp for the document
30+
# @option arguments [Time] :master_timeout Specify timeout for connection to master
31+
# @option arguments [Hash] :headers Custom HTTP headers
32+
# @option arguments [Hash] :body The data lifecycle configuration that consist of the data retention
33+
#
34+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/dlm-put-lifecycle.html
35+
#
36+
def put_data_lifecycle(arguments = {})
37+
arguments = arguments.clone
38+
headers = arguments.delete(:headers) || {}
39+
40+
body = arguments.delete(:body)
41+
42+
_name = arguments.delete(:name)
43+
44+
method = Elasticsearch::API::HTTP_PUT
45+
path = if _name
46+
"_data_stream/#{Utils.__listify(_name)}/_lifecycle"
47+
else
48+
"_data_stream/_lifecycle"
49+
end
50+
params = Utils.process_params(arguments)
51+
52+
Elasticsearch::API::Response.new(
53+
perform_request(method, path, params, body, headers)
54+
)
55+
end
56+
end
57+
end
58+
end
59+
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.indices#delete_data_lifecycle' do
21+
let(:expected_args) do
22+
[
23+
'DELETE',
24+
url,
25+
{},
26+
nil,
27+
{}
28+
]
29+
end
30+
31+
let(:url) { '_data_stream/_lifecycle'}
32+
33+
it 'performs the request' do
34+
expect(client_double.indices.delete_data_lifecycle).to be_a Elasticsearch::API::Response
35+
end
36+
37+
context 'when name is specified' do
38+
let(:url) { '_data_stream/foo/_lifecycle'}
39+
40+
it 'performs the request' do
41+
expect(client_double.indices.delete_data_lifecycle(name: 'foo')).to be_a Elasticsearch::API::Response
42+
end
43+
end
44+
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.indices#get_data_lifecycle' do
21+
let(:expected_args) do
22+
[
23+
'GET',
24+
url,
25+
{},
26+
nil,
27+
{}
28+
]
29+
end
30+
31+
let(:url) { '_data_stream/_lifecycle'}
32+
33+
it 'performs the request' do
34+
expect(client_double.indices.get_data_lifecycle).to be_a Elasticsearch::API::Response
35+
end
36+
37+
context 'when name is specified' do
38+
let(:url) { '_data_stream/foo/_lifecycle'}
39+
40+
it 'performs the request' do
41+
expect(client_double.indices.get_data_lifecycle(name: 'foo')).to be_a Elasticsearch::API::Response
42+
end
43+
end
44+
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.indices#put_data_lifecycle' do
21+
let(:expected_args) do
22+
[
23+
'PUT',
24+
url,
25+
{},
26+
nil,
27+
{}
28+
]
29+
end
30+
31+
let(:url) { '_data_stream/_lifecycle'}
32+
33+
it 'performs the request' do
34+
expect(client_double.indices.put_data_lifecycle).to be_a Elasticsearch::API::Response
35+
end
36+
37+
context 'when name is specified' do
38+
let(:url) { '_data_stream/foo/_lifecycle'}
39+
40+
it 'performs the request' do
41+
expect(client_double.indices.put_data_lifecycle(name: 'foo')).to be_a Elasticsearch::API::Response
42+
end
43+
end
44+
end

0 commit comments

Comments
 (0)