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.
25 26 27 28 29 30 31 |
# File 'lib/pritunl_api_client.rb', line 25 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)
38 39 40 |
# File 'lib/pritunl_api_client.rb', line 38 def event( cursor: nil ) @api.get( "/event/#{cursor}" ) end |
#key ⇒ PritunlApiClient::Key
Key apis
91 92 93 |
# File 'lib/pritunl_api_client.rb', line 91 def key @key ||= Key.new( @api ) end |
#log ⇒ Array
Returns a list of server log entries
63 64 65 |
# File 'lib/pritunl_api_client.rb', line 63 def log @api.get( '/log' ) end |
#organization ⇒ PritunlApiClient::Organization
Organization apis
77 78 79 |
# File 'lib/pritunl_api_client.rb', line 77 def organization @organization ||= Organization.new( @api ) end |
#ping ⇒ Boolean
Server healthcheck
45 46 47 48 49 50 51 |
# File 'lib/pritunl_api_client.rb', line 45 def ping begin @api.get( '/ping' ) == '' rescue false end end |
#server ⇒ PritunlApiClient::Server
Server apis
98 99 100 |
# File 'lib/pritunl_api_client.rb', line 98 def server @server ||= Server.new( @api ) end |
#settings ⇒ PritunlApiClient::Settings
Setting apis
70 71 72 |
# File 'lib/pritunl_api_client.rb', line 70 def settings @settings ||= Settings.new( @api ) end |
#status ⇒ Hash
Returns general information about the pritunl server
56 57 58 |
# File 'lib/pritunl_api_client.rb', line 56 def status @api.get( '/status' ) end |
#user ⇒ PritunlApiClient::User
User apis
84 85 86 |
# File 'lib/pritunl_api_client.rb', line 84 def user @user ||= User.new( @api ) end |