From c1dd03d76ef45a3380cba89cc07c8a3ca12eda38 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Tue, 7 Oct 2025 11:55:45 +0100 Subject: [PATCH] [API] Adds streams namespace and endpoints --- elasticsearch-api/lib/elasticsearch/api.rb | 3 +- .../api/actions/streams/logs_disable.rb | 52 +++++++++++++++++++ .../api/actions/streams/logs_enable.rb | 52 +++++++++++++++++++ .../api/actions/streams/status.rb | 50 ++++++++++++++++++ .../elasticsearch/api/namespace/streams.rb | 36 +++++++++++++ .../api/actions/streams/logs_disable_spec.rb | 35 +++++++++++++ .../api/actions/streams/logs_enable_spec.rb | 35 +++++++++++++ .../api/actions/streams/status_spec.rb | 35 +++++++++++++ 8 files changed, 297 insertions(+), 1 deletion(-) create mode 100644 elasticsearch-api/lib/elasticsearch/api/actions/streams/logs_disable.rb create mode 100644 elasticsearch-api/lib/elasticsearch/api/actions/streams/logs_enable.rb create mode 100644 elasticsearch-api/lib/elasticsearch/api/actions/streams/status.rb create mode 100644 elasticsearch-api/lib/elasticsearch/api/namespace/streams.rb create mode 100644 elasticsearch-api/spec/elasticsearch/api/actions/streams/logs_disable_spec.rb create mode 100644 elasticsearch-api/spec/elasticsearch/api/actions/streams/logs_enable_spec.rb create mode 100644 elasticsearch-api/spec/elasticsearch/api/actions/streams/status_spec.rb diff --git a/elasticsearch-api/lib/elasticsearch/api.rb b/elasticsearch-api/lib/elasticsearch/api.rb index a20a31a23b..2b8c298722 100644 --- a/elasticsearch-api/lib/elasticsearch/api.rb +++ b/elasticsearch-api/lib/elasticsearch/api.rb @@ -87,7 +87,8 @@ def self.included(base) Elasticsearch::API::Profiling, Elasticsearch::API::Simulate, Elasticsearch::API::Connector, - Elasticsearch::API::QueryRules + Elasticsearch::API::QueryRules, + Elasticsearch::API::Streams end # The serializer class diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/streams/logs_disable.rb b/elasticsearch-api/lib/elasticsearch/api/actions/streams/logs_disable.rb new file mode 100644 index 0000000000..c187e2212b --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/streams/logs_disable.rb @@ -0,0 +1,52 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# Auto generated from build hash Unavailable +# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec +# +module Elasticsearch + module API + module Streams + module Actions + # Disable the Logs Streams feature for this cluster + # + # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/guide/en/elasticsearch/reference/8.19/streams-logs-disable.html + # + def logs_disable(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'streams.logs_disable' } + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + method = Elasticsearch::API::HTTP_POST + path = '_streams/logs/_disable' + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/streams/logs_enable.rb b/elasticsearch-api/lib/elasticsearch/api/actions/streams/logs_enable.rb new file mode 100644 index 0000000000..d560f85d19 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/streams/logs_enable.rb @@ -0,0 +1,52 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# Auto generated from build hash Unavailable +# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec +# +module Elasticsearch + module API + module Streams + module Actions + # Enable the Logs Streams feature for this cluster + # + # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. + # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/guide/en/elasticsearch/reference/8.19/streams-logs-enable.html + # + def logs_enable(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'streams.logs_enable' } + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + method = Elasticsearch::API::HTTP_POST + path = '_streams/logs/_enable' + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/streams/status.rb b/elasticsearch-api/lib/elasticsearch/api/actions/streams/status.rb new file mode 100644 index 0000000000..9e9ca9c13c --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/streams/status.rb @@ -0,0 +1,50 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# Auto generated from build hash Unavailable +# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec +# +module Elasticsearch + module API + module Streams + module Actions + # Return the current status of the streams feature for each streams type + # + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/guide/en/elasticsearch/reference/8.19/streams-status.html + # + def status(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'streams.status' } + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + method = Elasticsearch::API::HTTP_GET + path = '_streams/status' + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/namespace/streams.rb b/elasticsearch-api/lib/elasticsearch/api/namespace/streams.rb new file mode 100644 index 0000000000..7d7f892d56 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/namespace/streams.rb @@ -0,0 +1,36 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +module Elasticsearch + module API + module Streams + module Actions; end + + # Client for the "streams" namespace (includes the {Streams::Actions} methods) + # + class StreamsClient + include Common::Client, Common::Client::Base, Streams::Actions + end + + # Proxy method for {StreamsClient}, available in the receiving object + # + def streams + @streams ||= StreamsClient.new(self) + end + end + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/streams/logs_disable_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/streams/logs_disable_spec.rb new file mode 100644 index 0000000000..c802267b5f --- /dev/null +++ b/elasticsearch-api/spec/elasticsearch/api/actions/streams/logs_disable_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +require 'spec_helper' + +describe 'client.streams#logs_disable' do + let(:expected_args) do + [ + 'POST', + '_streams/logs/_disable', + {}, + nil, + {}, + { endpoint: 'streams.logs_disable' } + ] + end + + it 'performs the request' do + expect(client_double.streams.logs_disable).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/streams/logs_enable_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/streams/logs_enable_spec.rb new file mode 100644 index 0000000000..ad4aa3f5aa --- /dev/null +++ b/elasticsearch-api/spec/elasticsearch/api/actions/streams/logs_enable_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +require 'spec_helper' + +describe 'client.streams#logs_enable' do + let(:expected_args) do + [ + 'POST', + '_streams/logs/_enable', + {}, + nil, + {}, + { endpoint: 'streams.logs_enable' } + ] + end + + it 'performs the request' do + expect(client_double.streams.logs_enable).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/elasticsearch/api/actions/streams/status_spec.rb b/elasticsearch-api/spec/elasticsearch/api/actions/streams/status_spec.rb new file mode 100644 index 0000000000..def22a386c --- /dev/null +++ b/elasticsearch-api/spec/elasticsearch/api/actions/streams/status_spec.rb @@ -0,0 +1,35 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +require 'spec_helper' + +describe 'client.streams#status' do + let(:expected_args) do + [ + 'GET', + '_streams/status', + {}, + nil, + {}, + { endpoint: 'streams.status' } + ] + end + + it 'performs the request' do + expect(client_double.streams.status).to be_a Elasticsearch::API::Response + end +end