Class: PritunlApiClient::Client
- Inherits:
-
Object
- Object
- PritunlApiClient::Client
- Defined in:
- lib/pritunl_api_client.rb
Overview
Main interface to the Pritunl api
Instance Method Summary collapse
-
#event(cursor: nil) ⇒ Array
Get a list of events (will poll up to 30 seconds).
-
#initialize(base_url:, api_token:, api_secret:, verify_ssl: true) ⇒ Client
constructor
A new instance of Client.
-
#key ⇒ PritunlApiClient::Key
Key apis.
-
#log ⇒ Array
Returns a list of server log entries.
-
#organization ⇒ PritunlApiClient::Organization
Organization apis.
-
#ping ⇒ Boolean
Server healthcheck.
-
#server ⇒ PritunlApiClient::Server
Server apis.
-
#settings ⇒ PritunlApiClient::Settings
Setting apis.
-
#status ⇒ Hash
Returns general information about the pritunl server.
-
#user ⇒ PritunlApiClient::User
User apis.
Constructor Details
#initialize(base_url:, api_token:, api_secret:, verify_ssl: true) ⇒ Client
Returns a new instance of Client.
24 25 26 27 28 29 30 |
# File 'lib/pritunl_api_client.rb', line 24 def initialize( base_url:, api_token:, api_secret:, verify_ssl: true ) @base_url = base_url @api_token = api_token @api_secret = api_secret @verify_ssl = verify_ssl @api = Api.new( base_url: base_url, api_token: api_token, api_secret: api_secret, verify_ssl: verify_ssl ) end |
Instance Method Details
#event(cursor: nil) ⇒ Array
Get a list of events (will poll up to 30 seconds)
37 38 39 |
# File 'lib/pritunl_api_client.rb', line 37 def event( cursor: nil ) @api.get( "/event/#{cursor}" ) end |
#key ⇒ PritunlApiClient::Key
Key apis
90 91 92 |
# File 'lib/pritunl_api_client.rb', line 90 def key @key ||= Key.new( @api ) end |
#log ⇒ Array
Returns a list of server log entries
62 63 64 |
# File 'lib/pritunl_api_client.rb', line 62 def log @api.get( '/log' ) end |
#organization ⇒ PritunlApiClient::Organization
Organization apis
76 77 78 |
# File 'lib/pritunl_api_client.rb', line 76 def organization @organization ||= Organization.new( @api ) end |
#ping ⇒ Boolean
Server healthcheck
44 45 46 47 48 49 50 |
# File 'lib/pritunl_api_client.rb', line 44 def ping begin @api.get( '/ping' ) == '' rescue false end end |
#server ⇒ PritunlApiClient::Server
Server apis
97 98 99 |
# File 'lib/pritunl_api_client.rb', line 97 def server @server ||= Server.new( @api ) end |
#settings ⇒ PritunlApiClient::Settings
Setting apis
69 70 71 |
# File 'lib/pritunl_api_client.rb', line 69 def settings @settings ||= Settings.new( @api ) end |
#status ⇒ Hash
Returns general information about the pritunl server
55 56 57 |
# File 'lib/pritunl_api_client.rb', line 55 def status @api.get( '/status' ) end |
#user ⇒ PritunlApiClient::User
User apis
83 84 85 |
# File 'lib/pritunl_api_client.rb', line 83 def user @user ||= User.new( @api ) end |