class PritunlApiClient::Client

Main interface to the Pritunl api

Public Class Methods

new( base_url:, api_token:, api_secret:, verify_ssl: true ) click to toggle source

@param base_url [String] Full URL to a running Pritunl server (include the “https://”) @param api_token [String @param api_secret [String] @param verify_ssl [Boolean] Whether or not to verify SSL certificate

# 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

Public Instance Methods

event( cursor: nil ) click to toggle source

Get a list of events (will poll up to 30 seconds)

@param cursor [String, NilClass] Optional id of last event. If left out, only events

that occurred after request is sent will be returned.

@return [Array]

# File lib/pritunl_api_client.rb, line 37
def event( cursor: nil )
  @api.get( "/event/#{cursor}" )
end
key() click to toggle source

Key apis

@return [PritunlApiClient::Key]

# File lib/pritunl_api_client.rb, line 90
def key
  @key ||= Key.new( @api )
end
log() click to toggle source

Returns a list of server log entries

@return [Array]

# File lib/pritunl_api_client.rb, line 62
def log
  @api.get( '/log' )
end
organization() click to toggle source

Organization apis

@return [PritunlApiClient::Organization]

# File lib/pritunl_api_client.rb, line 76
def organization
  @organization ||= Organization.new( @api )
end
ping() click to toggle source

Server healthcheck

@return [Boolean]

# File lib/pritunl_api_client.rb, line 44
def ping
  begin
    @api.get( '/ping' ) == ''
  rescue
    false
  end
end
server() click to toggle source

Server apis

@return [PritunlApiClient::Server]

# File lib/pritunl_api_client.rb, line 97
def server
  @server ||= Server.new( @api )
end
settings() click to toggle source

Setting apis

@return [PritunlApiClient::Settings]

# File lib/pritunl_api_client.rb, line 69
def settings
  @settings ||= Settings.new( @api )
end
status() click to toggle source

Returns general information about the pritunl server

@return [Hash]

# File lib/pritunl_api_client.rb, line 55
def status
  @api.get( '/status' )
end
user() click to toggle source

User apis

@return [PritunlApiClient::User]

# File lib/pritunl_api_client.rb, line 83
def user
  @user ||= User.new( @api )
end