Skip to content

Commit 0a7a3da

Browse files
committed
[API] Adds search_application.post_behavioral_analytics_event and search
1 parent 7e22bc4 commit 0a7a3da

File tree

5 files changed

+205
-5
lines changed

5 files changed

+205
-5
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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 SearchApplication
24+
module Actions
25+
# Creates a behavioral analytics event for existing collection.
26+
# This functionality is Experimental and may be changed or removed
27+
# completely in a future release. Elastic will take a best effort approach
28+
# to fix any issues, but experimental features are not subject to the
29+
# support SLA of official GA features.
30+
#
31+
# @option arguments [String] :collection_name The name of behavioral analytics collection
32+
# @option arguments [String] :event_type Behavioral analytics event type. Available: page_view, search, search_click
33+
# @option arguments [Hash] :headers Custom HTTP headers
34+
# @option arguments [Hash] :body The event definition (*Required*)
35+
#
36+
# @see http://todo.com/tbd
37+
#
38+
def post_behavioral_analytics_event(arguments = {})
39+
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
40+
raise ArgumentError, "Required argument 'collection_name' missing" unless arguments[:collection_name]
41+
raise ArgumentError, "Required argument 'event_type' missing" unless arguments[:event_type]
42+
43+
arguments = arguments.clone
44+
headers = arguments.delete(:headers) || {}
45+
46+
body = arguments.delete(:body)
47+
48+
_collection_name = arguments.delete(:collection_name)
49+
50+
_event_type = arguments.delete(:event_type)
51+
52+
method = Elasticsearch::API::HTTP_POST
53+
path = "_application/analytics/#{Utils.__listify(_collection_name)}/event/#{Utils.__listify(_event_type)}"
54+
params = {}
55+
56+
Elasticsearch::API::Response.new(
57+
perform_request(method, path, params, body, headers)
58+
)
59+
end
60+
end
61+
end
62+
end
63+
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 SearchApplication
24+
module Actions
25+
# Perform a search against a search application
26+
# This functionality is in Beta and is subject to change. The design and
27+
# code is less mature than official GA features and is being provided
28+
# as-is with no warranties. Beta features are not subject to the support
29+
# SLA of official GA features.
30+
#
31+
# @option arguments [String] :name The name of the search application to be searched
32+
# @option arguments [Hash] :headers Custom HTTP headers
33+
# @option arguments [Hash] :body Search parameters, including template parameters that override defaults
34+
#
35+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-application-search.html
36+
#
37+
def search(arguments = {})
38+
raise ArgumentError, "Required argument 'name' missing" unless arguments[:name]
39+
40+
arguments = arguments.clone
41+
headers = arguments.delete(:headers) || {}
42+
43+
body = arguments.delete(:body)
44+
45+
arguments[:index] = UNDERSCORE_ALL if !arguments[:index] && arguments[:type]
46+
47+
_name = arguments.delete(:name)
48+
49+
method = if body
50+
Elasticsearch::API::HTTP_POST
51+
else
52+
Elasticsearch::API::HTTP_GET
53+
end
54+
55+
path = "_application/search_application/#{Utils.__listify(_name)}/_search"
56+
params = {}
57+
58+
Elasticsearch::API::Response.new(
59+
perform_request(method, path, params, body, headers)
60+
)
61+
end
62+
end
63+
end
64+
end
65+
end

elasticsearch-api/spec/elasticsearch/api/actions/search_application/delete_behavioral_analytics_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
describe 'client.search_application#delete_behavioral_analytics' do
2121
let(:expected_args) do
2222
[
23-
'DELETE',
24-
'_application/analytics/foo',
25-
{},
26-
nil,
27-
{}
23+
'DELETE',
24+
'_application/analytics/foo',
25+
{},
26+
nil,
27+
{}
2828
]
2929
end
3030

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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.search_application#delete_behavioral_analytics_event' do
21+
let(:expected_args) do
22+
[
23+
'POST',
24+
'_application/analytics/foo/event/search',
25+
{},
26+
{},
27+
{}
28+
]
29+
end
30+
31+
it 'performs the request' do
32+
expect(
33+
client_double.search_application.post_behavioral_analytics_event(
34+
body: {}, collection_name: 'foo', event_type: 'search'
35+
)
36+
).to be_a Elasticsearch::API::Response
37+
end
38+
end
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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.search_application#delete_behavioral_analytics' do
21+
let(:expected_args) do
22+
[
23+
'GET',
24+
'_application/search_application/foo/_search',
25+
{},
26+
nil,
27+
{}
28+
]
29+
end
30+
31+
it 'performs the request' do
32+
expect(client_double.search_application.search(name: 'foo')).to be_a Elasticsearch::API::Response
33+
end
34+
end

0 commit comments

Comments
 (0)