class PritunlApiClient::Server
Interact with /server api's
Public Class Methods
@param api [PritunlApiClient::Api]
# File lib/pritunl_api_client/server.rb, line 7 def initialize( api ) @api = api end
Public Instance Methods
Returns a list of servers
@return [Array]
# File lib/pritunl_api_client/server.rb, line 14 def all @api.get( '/server' ) end
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 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 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 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
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
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
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 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 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 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 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 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