Skip to content

Commit 1a6b85b

Browse files
committed
[API] Adds geoip_database endpoints - delete, get, put
1 parent ca88f25 commit 1a6b85b

File tree

6 files changed

+307
-0
lines changed

6 files changed

+307
-0
lines changed
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 build hash f284cc16f4d4b4289bc679aa1529bb504190fe80
19+
# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec
20+
#
21+
module Elasticsearch
22+
module API
23+
module Ingest
24+
module Actions
25+
# Deletes a geoip database configuration
26+
#
27+
# @option arguments [List] :id A comma-separated list of geoip database configurations to delete
28+
# @option arguments [Hash] :headers Custom HTTP headers
29+
#
30+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/TODO.html
31+
#
32+
def delete_geoip_database(arguments = {})
33+
request_opts = { endpoint: arguments[:endpoint] || 'ingest.delete_geoip_database' }
34+
35+
defined_params = [:id].each_with_object({}) do |variable, set_variables|
36+
set_variables[variable] = arguments[variable] if arguments.key?(variable)
37+
end
38+
request_opts[:defined_params] = defined_params unless defined_params.empty?
39+
40+
raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
41+
42+
arguments = arguments.clone
43+
headers = arguments.delete(:headers) || {}
44+
45+
body = nil
46+
47+
_id = arguments.delete(:id)
48+
49+
method = Elasticsearch::API::HTTP_DELETE
50+
path = "_ingest/geoip/database/#{Utils.__listify(_id)}"
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: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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 Ingest
24+
module Actions
25+
# Returns geoip database configuration.
26+
#
27+
# @option arguments [List] :id A comma-separated list of geoip database configurations to get; use `*` to get all geoip database configurations
28+
# @option arguments [Hash] :headers Custom HTTP headers
29+
#
30+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/TODO.html
31+
#
32+
def get_geoip_database(arguments = {})
33+
request_opts = { endpoint: arguments[:endpoint] || 'ingest.get_geoip_database' }
34+
35+
defined_params = [:id].each_with_object({}) do |variable, set_variables|
36+
set_variables[variable] = arguments[variable] if arguments.key?(variable)
37+
end
38+
request_opts[:defined_params] = defined_params unless defined_params.empty?
39+
40+
arguments = arguments.clone
41+
headers = arguments.delete(:headers) || {}
42+
43+
body = nil
44+
45+
_id = arguments.delete(:id)
46+
47+
method = Elasticsearch::API::HTTP_GET
48+
path = if _id
49+
"_ingest/geoip/database/#{Utils.__listify(_id)}"
50+
else
51+
'_ingest/geoip/database'
52+
end
53+
params = {}
54+
55+
Elasticsearch::API::Response.new(
56+
perform_request(method, path, params, body, headers, request_opts)
57+
)
58+
end
59+
end
60+
end
61+
end
62+
end
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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 Ingest
24+
module Actions
25+
# Puts the configuration for a geoip database to be downloaded
26+
#
27+
# @option arguments [String] :id The id of the database configuration
28+
# @option arguments [Hash] :headers Custom HTTP headers
29+
# @option arguments [Hash] :body The database configuration definition (*Required*)
30+
#
31+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/TODO.html
32+
#
33+
def put_geoip_database(arguments = {})
34+
request_opts = { endpoint: arguments[:endpoint] || 'ingest.put_geoip_database' }
35+
36+
defined_params = [:id].each_with_object({}) do |variable, set_variables|
37+
set_variables[variable] = arguments[variable] if arguments.key?(variable)
38+
end
39+
request_opts[:defined_params] = defined_params unless defined_params.empty?
40+
41+
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
42+
raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
43+
44+
arguments = arguments.clone
45+
headers = arguments.delete(:headers) || {}
46+
47+
body = arguments.delete(:body)
48+
49+
_id = arguments.delete(:id)
50+
51+
method = Elasticsearch::API::HTTP_PUT
52+
path = "_ingest/geoip/database/#{Utils.__listify(_id)}"
53+
params = {}
54+
55+
Elasticsearch::API::Response.new(
56+
perform_request(method, path, params, body, headers, request_opts)
57+
)
58+
end
59+
end
60+
end
61+
end
62+
end
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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.ingest#delete_geoip_database' do
21+
let(:expected_args) do
22+
[
23+
'DELETE',
24+
'_ingest/geoip/database/foo',
25+
{},
26+
nil,
27+
{},
28+
{ defined_params: { id: 'foo' }, endpoint: 'ingest.delete_geoip_database' }
29+
]
30+
end
31+
32+
let(:client) do
33+
Class.new { include Elasticsearch::API }.new
34+
end
35+
36+
it 'performs the request' do
37+
expect(client_double.ingest.delete_geoip_database(id: 'foo', body: {})).to be_a Elasticsearch::API::Response
38+
end
39+
end
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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.ingest#get_geoip_database' do
21+
let(:expected_args) do
22+
[
23+
'GET',
24+
'_ingest/geoip/database/foo',
25+
{},
26+
nil,
27+
{},
28+
{ defined_params: { id: 'foo' }, endpoint: 'ingest.get_geoip_database' }
29+
]
30+
end
31+
32+
let(:client) do
33+
Class.new { include Elasticsearch::API }.new
34+
end
35+
36+
it 'performs the request' do
37+
expect(client_double.ingest.get_geoip_database(id: 'foo', body: {})).to be_a Elasticsearch::API::Response
38+
end
39+
end
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 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.ingest#put_geoip_database' do
21+
let(:expected_args) do
22+
[
23+
'PUT',
24+
'_ingest/geoip/database/foo',
25+
{},
26+
{},
27+
{},
28+
{ defined_params: { id: 'foo' }, endpoint: 'ingest.put_geoip_database' }
29+
]
30+
end
31+
32+
let(:client) do
33+
Class.new { include Elasticsearch::API }.new
34+
end
35+
36+
it 'requires the :id argument' do
37+
expect {
38+
client.ingest.put_geoip_database
39+
}.to raise_exception(ArgumentError)
40+
end
41+
42+
it 'performs the request' do
43+
expect(client_double.ingest.put_geoip_database(id: 'foo', body: {})).to be_a Elasticsearch::API::Response
44+
end
45+
end

0 commit comments

Comments
 (0)