Class: PiholeApi::Client
- Inherits:
-
Object
- Object
- PiholeApi::Client
- Includes:
- AuthorisedEndpoints, AuthorisedFormEndpoints, Constants, UnauthorisedEndpoints
- Defined in:
- lib/pihole-api/client.rb
Constant Summary
Constants included from Constants
PiholeApi::Constants::API_PATH, PiholeApi::Constants::INDEX_PATH, PiholeApi::Constants::LOGIN_PATH, PiholeApi::Constants::TELEPORTER_PATH, PiholeApi::Constants::TOKEN_REGEX, PiholeApi::Constants::TOKEN_SEPERATOR
Instance Attribute Summary collapse
-
#api_token ⇒ Object
readonly
Returns the value of attribute api_token.
-
#base_path ⇒ Object
readonly
Returns the value of attribute base_path.
-
#cookie ⇒ Object
readonly
Returns the value of attribute cookie.
-
#form_token ⇒ Object
readonly
Returns the value of attribute form_token.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Class Method Summary collapse
-
.api_version ⇒ Object
This is the version of the API docs this client was built off-of.
- .compatible_api_version ⇒ Object
- .hash_password(password) ⇒ Object
Instance Method Summary collapse
-
#initialize(base_path:, password:, port: 80) ⇒ Client
constructor
A new instance of Client.
Methods included from AuthorisedEndpoints
#disable, #enable, #get_all_queries, #get_forward_destinations, #get_query_sources, #get_query_types, #over_time_data_10_mins, #recent_blocked, #summary, #summary_raw, #top_clients, #top_items
Methods included from UnauthorisedEndpoints
Constructor Details
#initialize(base_path:, password:, port: 80) ⇒ Client
Returns a new instance of Client.
12 13 14 15 16 17 18 |
# File 'lib/pihole-api/client.rb', line 12 def initialize(base_path:, password:, port: 80) @password = password @api_token = PiholeApi::Client.hash_password(password) @base_path = base_path @port = port end |
Instance Attribute Details
#api_token ⇒ Object (readonly)
Returns the value of attribute api_token.
10 11 12 |
# File 'lib/pihole-api/client.rb', line 10 def api_token @api_token end |
#base_path ⇒ Object (readonly)
Returns the value of attribute base_path.
10 11 12 |
# File 'lib/pihole-api/client.rb', line 10 def base_path @base_path end |
#cookie ⇒ Object (readonly)
Returns the value of attribute cookie.
10 11 12 |
# File 'lib/pihole-api/client.rb', line 10 def @cookie end |
#form_token ⇒ Object (readonly)
Returns the value of attribute form_token.
10 11 12 |
# File 'lib/pihole-api/client.rb', line 10 def form_token @form_token end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
10 11 12 |
# File 'lib/pihole-api/client.rb', line 10 def password @password end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
10 11 12 |
# File 'lib/pihole-api/client.rb', line 10 def port @port end |
Class Method Details
.api_version ⇒ Object
This is the version of the API docs this client was built off-of
25 26 27 |
# File 'lib/pihole-api/client.rb', line 25 def self.api_version 'v2 2023-01-21' end |
.compatible_api_version ⇒ Object
20 21 22 |
# File 'lib/pihole-api/client.rb', line 20 def self.compatible_api_version 'v3' end |
.hash_password(password) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/pihole-api/client.rb', line 29 def self.hash_password(password) require 'digest' hash1 = Digest::SHA256.hexdigest(password) Digest::SHA256.hexdigest(hash1) # Use as hash password for client end |