Class: PritunlApiClient::Server
- Inherits:
-
Object
- Object
- PritunlApiClient::Server
- Defined in:
- lib/pritunl_api_client/server.rb
Overview
Interact with /server api’s
Instance Method Summary collapse
-
#all ⇒ Array
Returns a list of servers.
-
#attach_organization(id, organization_id:) ⇒ Hash
Attach an organization to an existing server.
-
#clear_output(id) ⇒ Object
Clear the output of a server.
-
#create(params) ⇒ Hash
Create a new server.
-
#delete(id) ⇒ Object
Delete an existing server.
-
#find(id) ⇒ Hash
Returns a server.
-
#initialize(api) ⇒ Server
constructor
A new instance of Server.
-
#organizations(id) ⇒ Array
Returns a list of organizations attached to a server.
-
#output(id) ⇒ Hash
Get the output of a server.
-
#remove_organization(id, organization_id:) ⇒ Object
Remove an organization from an existing server.
-
#restart(id) ⇒ Hash
Restart an existing server.
-
#start(id) ⇒ Hash
Start an existing server.
-
#stop(id) ⇒ Hash
Stop an existing server.
-
#update(id, params) ⇒ Hash
Update an existing server.
Constructor Details
#initialize(api) ⇒ Server
Returns a new instance of Server.
7 8 9 |
# File 'lib/pritunl_api_client/server.rb', line 7 def initialize( api ) @api = api end |
Instance Method Details
#all ⇒ Array
Returns a list of servers
14 15 16 |
# File 'lib/pritunl_api_client/server.rb', line 14 def all @api.get( '/server' ) end |
#attach_organization(id, organization_id:) ⇒ Hash
Attach an organization to an existing server
90 91 92 |
# 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) ⇒ Object
Clear the output of a server
112 113 114 |
# File 'lib/pritunl_api_client/server.rb', line 112 def clear_output( id ) @api.delete( "/server/#{id}/output" ) end |
#create(params) ⇒ Hash
Create a new server
31 32 33 34 |
# 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) ⇒ Object
Delete an existing server
50 51 52 |
# File 'lib/pritunl_api_client/server.rb', line 50 def delete( id ) @api.delete( "/server/#{id}" ) end |
#find(id) ⇒ Hash
Returns a server
22 23 24 |
# File 'lib/pritunl_api_client/server.rb', line 22 def find( id ) @api.get( "/server/#{id}" ) end |
#organizations(id) ⇒ Array
Returns a list of organizations attached to a server
82 83 84 |
# File 'lib/pritunl_api_client/server.rb', line 82 def organizations( id ) @api.get( "/server/#{id}/organization" ) end |
#output(id) ⇒ Hash
Get the output of a server
105 106 107 |
# File 'lib/pritunl_api_client/server.rb', line 105 def output( id ) @api.get( "/server/#{id}/output" ) end |
#remove_organization(id, organization_id:) ⇒ Object
Remove an organization from an existing server
97 98 99 |
# 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) ⇒ Hash
Restart an existing server
74 75 76 |
# File 'lib/pritunl_api_client/server.rb', line 74 def restart( id ) @api.put( "/server/#{id}/restart" ) end |
#start(id) ⇒ Hash
Start an existing server
58 59 60 |
# File 'lib/pritunl_api_client/server.rb', line 58 def start( id ) @api.put( "/server/#{id}/start" ) end |
#stop(id) ⇒ Hash
Stop an existing server
66 67 68 |
# File 'lib/pritunl_api_client/server.rb', line 66 def stop( id ) @api.put( "/server/#{id}/stop" ) end |
#update(id, params) ⇒ Hash
Update an existing server
42 43 44 45 |
# 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 |