jay_api 27.5.1 → 28.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/lib/jay_api/configuration.rb +7 -1
- data/lib/jay_api/elasticsearch/client.rb +7 -0
- data/lib/jay_api/elasticsearch/stats/index.rb +19 -0
- data/lib/jay_api/elasticsearch/stats/indices.rb +64 -0
- data/lib/jay_api/elasticsearch/stats.rb +39 -0
- data/lib/jay_api/elasticsearch.rb +1 -0
- data/lib/jay_api/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b2d35c2ed340724fe54f7f099ed3fb5f200249c72604b906a39ecdef13be6fb
|
4
|
+
data.tar.gz: 4da5c5a7dca36ea23ca6241ac5f44846558d620a60ce9382dff422ca3575f4fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74414baf82a02115568311cfce173e990c3777da5d3a18eed084366048968f88c1a42e581a2652544cc9952ff1e32b135528c622cd2d30554a429c952b544aa2
|
7
|
+
data.tar.gz: 5bbe6985eb4d5b3bd1263f1ebd6d23f83afb2a9b5eb48bce31a710628bdd35f6051c0b643bcdaab8c22ffc977b90e4bd79e3b94468a9d8b0b0984065408df92a
|
data/CHANGELOG.md
CHANGED
@@ -8,6 +8,23 @@ Please mark backwards incompatible changes with an exclamation mark at the start
|
|
8
8
|
|
9
9
|
## [Unreleased]
|
10
10
|
|
11
|
+
## [28.1.0] - 2025-05-19
|
12
|
+
|
13
|
+
### Added
|
14
|
+
- The `#stats` method to the `Elasticsearch::Client` class. The method returns
|
15
|
+
an object that can be used to retrieve statistics about the Cluster. For the
|
16
|
+
moment only `#indices` is available, which returns index-related statistics.
|
17
|
+
|
18
|
+
## [28.0.0] - 2025-05-09
|
19
|
+
|
20
|
+
### Added
|
21
|
+
- ! The `#keys` method to the `Configuration` class. The method returns the
|
22
|
+
array of keys that the `Configuration` object has.
|
23
|
+
|
24
|
+
Note that the addition of this method means that it is no longer possible to
|
25
|
+
access the value of an attribute called `keys` via the dot syntax, however,
|
26
|
+
it is still possible to access its value using the brackets: `[]`
|
27
|
+
|
11
28
|
## [27.5.1] - 2025-04-24
|
12
29
|
|
13
30
|
### Fixed
|
@@ -89,6 +89,12 @@ module JayAPI
|
|
89
89
|
YAML.dump(deep_to_h.deep_stringify_keys)
|
90
90
|
end
|
91
91
|
|
92
|
+
# @return [Array<Object>] An array with the keys (generally the name of the
|
93
|
+
# attributes) that the configuration object has.
|
94
|
+
def keys
|
95
|
+
@table.keys
|
96
|
+
end
|
97
|
+
|
92
98
|
private
|
93
99
|
|
94
100
|
# Takes a value and transforms it in accordance to its type.
|
@@ -104,7 +110,7 @@ module JayAPI
|
|
104
110
|
when self.class
|
105
111
|
value.deep_to_h
|
106
112
|
when Hash
|
107
|
-
value.
|
113
|
+
value.transform_values { |hash_value| value_for_h(hash_value) }
|
108
114
|
when Array
|
109
115
|
value.map { |element| value_for_h(element) }
|
110
116
|
else
|
@@ -6,6 +6,7 @@ require 'faraday/error'
|
|
6
6
|
require 'forwardable'
|
7
7
|
|
8
8
|
require_relative '../abstract/connection'
|
9
|
+
require_relative 'stats'
|
9
10
|
|
10
11
|
module JayAPI
|
11
12
|
module Elasticsearch
|
@@ -91,6 +92,12 @@ module JayAPI
|
|
91
92
|
retry_request { transport_client.tasks.get(**args) }
|
92
93
|
end
|
93
94
|
|
95
|
+
# @return [JayAPI::Elasticsearch::Stats] An instance of the +Stats+ class,
|
96
|
+
# which gives the caller access to Elasticsearch's Statistics API.
|
97
|
+
def stats
|
98
|
+
@stats ||= ::JayAPI::Elasticsearch::Stats.new(transport_client)
|
99
|
+
end
|
100
|
+
|
94
101
|
private
|
95
102
|
|
96
103
|
# @param [Proc] block The block to execute.
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module JayAPI
|
4
|
+
module Elasticsearch
|
5
|
+
class Stats
|
6
|
+
# Holds information about an Elasticsearch Index.
|
7
|
+
class Index
|
8
|
+
attr_reader :name
|
9
|
+
|
10
|
+
# @param [String] name The name of the index.
|
11
|
+
# @param [Hash] data Information about the index.
|
12
|
+
def initialize(name, data)
|
13
|
+
@name = name
|
14
|
+
@data = data
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'index'
|
4
|
+
|
5
|
+
module JayAPI
|
6
|
+
module Elasticsearch
|
7
|
+
class Stats
|
8
|
+
# Provides access to the list of indices returned by Elasticsearch's
|
9
|
+
# Stats API
|
10
|
+
class Indices
|
11
|
+
# A lambda used to select / reject system indices (indices whose name
|
12
|
+
# starts with dot).
|
13
|
+
SYSTEM_SELECTOR = ->(name, _data) { name.starts_with?('.') }
|
14
|
+
|
15
|
+
# @param [Hash{String=>Hash}] indices A +Hash+ with the information
|
16
|
+
# about the indices. Its keys are the names of the indices, its values
|
17
|
+
# hashes with information about each of the indices.
|
18
|
+
def initialize(indices)
|
19
|
+
@indices = indices
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Enumerator::Lazy<JayAPI::Elasticsearch::Stats::Index>] A lazy
|
23
|
+
# enumerator of +Index+ objects, one for each of the indexes. All
|
24
|
+
# indices (system and user-defined are included).
|
25
|
+
def all
|
26
|
+
@all ||= with_lazy_instantiation { indices }
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [Enumerator::Lazy<JayAPI::Elasticsearch::Stats::Index>] A lazy
|
30
|
+
# enumerator of +Index+ objects. Includes only the system indices.
|
31
|
+
def system
|
32
|
+
@system ||= with_lazy_instantiation { indices.select(&SYSTEM_SELECTOR) }
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [Enumerator::Lazy<JayAPI::Elasticsearch::Stats::Index>] A lazy
|
36
|
+
# enumerator of +Index+ objects. Includes only the user-defined
|
37
|
+
# indices.
|
38
|
+
def user
|
39
|
+
@user ||= with_lazy_instantiation { indices.reject(&SYSTEM_SELECTOR) }
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
attr_reader :indices
|
45
|
+
|
46
|
+
# @param [Array(String, Hash)] args An array with two elements, the name
|
47
|
+
# of the index and its information.
|
48
|
+
# @return [JayAPI::Elasticsearch::Stats::Index] An +Index+ object
|
49
|
+
# representing the given index.
|
50
|
+
def build_index(args)
|
51
|
+
JayAPI::Elasticsearch::Stats::Index.new(*args)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Calls the given block and turns its return value into a lazy
|
55
|
+
# enumerator that instantiates an +Index+ object for each of the
|
56
|
+
# elements of the collection returned by block.
|
57
|
+
# @return [Enumerator::Lazy<JayAPI::Elasticsearch::Stats::Index>]
|
58
|
+
def with_lazy_instantiation(&block)
|
59
|
+
block.call.lazy.map(&method(:build_index))
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'stats/index'
|
4
|
+
require_relative 'stats/indices'
|
5
|
+
|
6
|
+
module JayAPI
|
7
|
+
module Elasticsearch
|
8
|
+
# This class provides access to Elasticsearch's Cluster Statistic API.
|
9
|
+
class Stats
|
10
|
+
attr_reader :transport_client, :logger
|
11
|
+
|
12
|
+
# @param [Elasticsearch::Transport::Client] transport_client The transport
|
13
|
+
# client to use to make requests to the cluster.
|
14
|
+
def initialize(transport_client)
|
15
|
+
@transport_client = transport_client
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [JayAPI::Elasticsearch::Stats::Indices] Information about the
|
19
|
+
# indices that exist in the Elasticsearch cluster.
|
20
|
+
# @raise [Elasticsearch::Transport::Transport::ServerError] If the request
|
21
|
+
# to the Statistics API endpoint fails.
|
22
|
+
def indices
|
23
|
+
# DO NOT MEMOIZE! Leave it to the caller.
|
24
|
+
::JayAPI::Elasticsearch::Stats::Indices.new(response['indices'])
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
# @return [Hash] The Hash with the statistics returned by the
|
30
|
+
# Elasticsearch cluster.
|
31
|
+
# @raise [Elasticsearch::Transport::Transport::ServerError] If the
|
32
|
+
# request fails.
|
33
|
+
def response
|
34
|
+
# DO NOT MEMOIZE! Leave it to the caller.
|
35
|
+
transport_client.indices.stats
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -10,6 +10,7 @@ require_relative 'elasticsearch/query_builder'
|
|
10
10
|
require_relative 'elasticsearch/query_results'
|
11
11
|
require_relative 'elasticsearch/response'
|
12
12
|
require_relative 'elasticsearch/search_after_results'
|
13
|
+
require_relative 'elasticsearch/stats'
|
13
14
|
require_relative 'elasticsearch/tasks'
|
14
15
|
require_relative 'elasticsearch/time'
|
15
16
|
|
data/lib/jay_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jay_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 28.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Accenture-Industry X
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2025-
|
12
|
+
date: 2025-05-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -171,6 +171,9 @@ files:
|
|
171
171
|
- lib/jay_api/elasticsearch/query_results.rb
|
172
172
|
- lib/jay_api/elasticsearch/response.rb
|
173
173
|
- lib/jay_api/elasticsearch/search_after_results.rb
|
174
|
+
- lib/jay_api/elasticsearch/stats.rb
|
175
|
+
- lib/jay_api/elasticsearch/stats/index.rb
|
176
|
+
- lib/jay_api/elasticsearch/stats/indices.rb
|
174
177
|
- lib/jay_api/elasticsearch/tasks.rb
|
175
178
|
- lib/jay_api/elasticsearch/time.rb
|
176
179
|
- lib/jay_api/errors/configuration_error.rb
|