Class: Opendistro::Client
- Includes:
- Users
- Defined in:
- lib/opendistro/client.rb,
lib/opendistro/client/users.rb
Overview
Wrapper for the Opendistro REST API.
Defined Under Namespace
Modules: Users
Instance Attribute Summary
Attributes inherited from Request
#ca_cert, #endpoint, #password, #username, #verify_ssl
Instance Method Summary collapse
-
#inspect ⇒ String
Text representation of the client, masking private token.
- #only_show_last_four_chars(password) ⇒ Object
-
#url_encode(url) ⇒ String
Utility method for URL encoding of a string.
Methods included from Users
#create_user, #delete_user, #edit_user, #user, #users
Methods inherited from API
Methods inherited from Request
decode, parse, #request_defaults, #validate
Constructor Details
This class inherits a constructor from Opendistro::API
Instance Method Details
#inspect ⇒ String
Text representation of the client, masking private token.
14 15 16 17 18 |
# File 'lib/opendistro/client.rb', line 14 def inspect inspected = super inspected.sub! @password, only_show_last_four_chars(@password) if @password inspected end |
#only_show_last_four_chars(password) ⇒ Object
28 29 30 |
# File 'lib/opendistro/client.rb', line 28 def only_show_last_four_chars(password) "#{'*' * (password.size - 4)}#{password[-4..-1]}" end |
#url_encode(url) ⇒ String
Utility method for URL encoding of a string. Copied from ruby-doc.org/stdlib-2.7.0/libdoc/erb/rdoc/ERB/Util.html
24 25 26 |
# File 'lib/opendistro/client.rb', line 24 def url_encode(url) url.to_s.b.gsub(/[^a-zA-Z0-9_\-.~]/n) { |m| sprintf('%%%02X', m.unpack1('C')) } # rubocop:disable Style/FormatString, Style/FormatStringToken end |