class PritunlApiClient::Server

Interact with /server api's

Public Class Methods

new( api ) click to toggle source

@param api [PritunlApiClient::Api]

# File lib/pritunl_api_client/server.rb, line 7
def initialize( api )
  @api = api
end

Public Instance Methods

all() click to toggle source

Returns a list of servers

@return [Array]

# File lib/pritunl_api_client/server.rb, line 14
def all
  @api.get( '/server' )
end
attach_organization( id, organization_id: ) click to toggle source

Attach an organization to an existing server

@param id [String] Server ID @return [Hash]

# File lib/pritunl_api_client/server.rb, line 90
def attach_organization( id, organization_id: )
  @api.put( "/server/#{id}/organization/#{organization_id}" )
end
clear_output( id ) click to toggle source

Clear the output of a server

@param id [String] Server ID

# File lib/pritunl_api_client/server.rb, line 112
def clear_output( id )
  @api.delete( "/server/#{id}/output" )
end
create( params ) click to toggle source

Create a new server

@param params [Hash] @raise [ArgumentError] if params is not a Hash @return [Hash]

# File lib/pritunl_api_client/server.rb, line 31
def create( params )
  fail ArgumentError, 'params must be a Hash' unless params.is_a? Hash
  @api.post( '/server', params )
end
delete( id ) click to toggle source

Delete an existing server

@param id [String] Server ID

# File lib/pritunl_api_client/server.rb, line 50
def delete( id )
  @api.delete( "/server/#{id}" )
end
find( id ) click to toggle source

Returns a server

@param id [String] Server ID @return [Hash]

# File lib/pritunl_api_client/server.rb, line 22
def find( id )
  @api.get( "/server/#{id}" )
end
organizations( id ) click to toggle source

Returns a list of organizations attached to a server

@param id [String] Server ID @return [Array]

# File lib/pritunl_api_client/server.rb, line 82
def organizations( id )
  @api.get( "/server/#{id}/organization" )
end
output( id ) click to toggle source

Get the output of a server

@param id [String] Server ID @return [Hash]

# File lib/pritunl_api_client/server.rb, line 105
def output( id )
  @api.get( "/server/#{id}/output" )
end
remove_organization( id, organization_id: ) click to toggle source

Remove an organization from an existing server

@param id [String] Server ID

# File lib/pritunl_api_client/server.rb, line 97
def remove_organization( id, organization_id: )
  @api.delete( "/server/#{id}/organization/#{organization_id}" )
end
restart( id ) click to toggle source

Restart an existing server

@param id [String] Server ID @return [Hash]

# File lib/pritunl_api_client/server.rb, line 74
def restart( id )
  @api.put( "/server/#{id}/restart" )
end
start( id ) click to toggle source

Start an existing server

@param id [String] Server ID @return [Hash]

# File lib/pritunl_api_client/server.rb, line 58
def start( id )
  @api.put( "/server/#{id}/start" )
end
stop( id ) click to toggle source

Stop an existing server

@param id [String] Server ID @return [Hash]

# File lib/pritunl_api_client/server.rb, line 66
def stop( id )
  @api.put( "/server/#{id}/stop" )
end
update( id, params ) click to toggle source

Update an existing server

@param id [String] Server ID @param params [Hash] @raise [ArgumentError] if params is not a Hash @return [Hash]

# File lib/pritunl_api_client/server.rb, line 42
def update( id, params )
  fail ArgumentError, 'params must be a Hash' unless params.is_a? Hash
  @api.put( "/server/#{id}", params )
end