Skip to content

Commit a60c79e

Browse files
committed
[XPACK] Add update_data_frame_transform
1 parent 2ee6c4c commit a60c79e

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Licensed to Elasticsearch B.V under one or more agreements.
2+
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
# See the LICENSE file in the project root for more information
4+
5+
module Elasticsearch
6+
module XPack
7+
module API
8+
module DataFrame
9+
module Actions
10+
11+
# Updates an existing data frame transform.
12+
#
13+
# @option arguments [Hash] :transform_id The id of the new transform. *Required*
14+
# @option arguments [Hash] :body The update data frame transform definition. *Required*
15+
# @option arguments [Boolean] :defer_validation If validations should be deferred until data frame
16+
# transform starts, defaults to false.
17+
#
18+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/update-data-frame-transform.html
19+
#
20+
# @since 7.4.0
21+
def update_data_frame_transform(arguments={})
22+
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
23+
raise ArgumentError, "Required argument 'transform_id' missing" unless arguments[:transform_id]
24+
arguments = arguments.clone
25+
26+
transform_id = URI.escape(arguments.delete(:transform_id))
27+
body = arguments.delete(:body)
28+
29+
method = Elasticsearch::API::HTTP_POST
30+
path = "_data_frame/transforms/#{transform_id}/_update"
31+
params = Elasticsearch::API::Utils.__validate_and_extract_params(arguments, ParamsRegistry.get(__method__))
32+
33+
perform_request(method, path, params, body).body
34+
end
35+
36+
37+
# Register this action with its valid params when the module is loaded.
38+
#
39+
# @since 7.4.0
40+
ParamsRegistry.register(:update_data_frame_transform, [ :defer_validation ].freeze)
41+
end
42+
end
43+
end
44+
end
45+
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 agreements.
2+
# Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
# See the LICENSE file in the project root for more information
4+
5+
require 'spec_helper'
6+
7+
describe 'client#update_data_frame_transform' do
8+
9+
let(:expected_args) do
10+
[
11+
'POST',
12+
'_data_frame/transforms/foo/_update',
13+
params,
14+
{},
15+
nil
16+
]
17+
end
18+
19+
let(:params) do
20+
{}
21+
end
22+
23+
it 'performs the request' do
24+
expect(client_double.data_frame.
25+
update_data_frame_transform(transform_id: 'foo', body: {})).to eq({})
26+
end
27+
28+
context 'when body is not provided' do
29+
30+
let(:client) do
31+
Class.new { include Elasticsearch::XPack::API }.new
32+
end
33+
34+
it 'raises an exception' do
35+
expect {
36+
client.data_frame.update_data_frame_transform(transform_id: 'foo')
37+
}.to raise_exception(ArgumentError)
38+
end
39+
end
40+
41+
context 'when a transform_id is not provided' do
42+
43+
let(:client) do
44+
Class.new { include Elasticsearch::XPack::API }.new
45+
end
46+
47+
it 'raises an exception' do
48+
expect {
49+
client.data_frame.update_data_frame_transform(body: {})
50+
}.to raise_exception(ArgumentError)
51+
end
52+
end
53+
54+
context 'when params are specified' do
55+
56+
let(:params) do
57+
{ defer_validation: true }
58+
end
59+
60+
it 'performs the request' do
61+
expect(client_double.data_frame.
62+
update_data_frame_transform(transform_id: 'foo', body: {}, defer_validation: true)).to eq({})
63+
end
64+
end
65+
end

0 commit comments

Comments
 (0)