Module: Terminal::Modules::CreateAndManageTerminals

Includes:
Utils
Included in:
API
Defined in:
lib/terminal/modules/create_and_manage_terminals.rb

Instance Method Summary collapse

Instance Method Details

#delete_terminal(container_key) ⇒ Hash

Delete a terminal instance

Parameters:

  • container_key (String)

    the key of the terminal you are trying to delete

Returns:

  • (Hash)

    represents the :status of the request and the :result

See Also:

Authentication:

  • Requires user_token and access_token



60
61
62
63
64
65
# File 'lib/terminal/modules/create_and_manage_terminals.rb', line 60

def delete_terminal(container_key)
  options = {}
  options[:auth] = true
  options[:container_key] = container_key
  perform(:post, 'delete_terminal', options)
end

#edit_terminal(container_key, required_options = {}) ⇒ Hash

Edit the resources and/or name of a Terminal instance

Parameters:

  • container_key (String)

    the id of the terminal you are trying to edit

  • required_options (Hash) (defaults to: {})

    hash of other required params cpu, ram, diskspace, name

Returns:

  • (Hash)

    Hash containing the :status and the :request_id for the request

See Also:

Authentication:

  • Requires user_token and access_token

Required Option:

  • cpu [String] cpu of the terminal to edit to

  • ram [String] ram to edit the terminal to

  • cpu [String] disk space to edit to

  • name [String] name to edit the terminal to



117
118
119
120
121
# File 'lib/terminal/modules/create_and_manage_terminals.rb', line 117

def edit_terminal(container_key, required_options ={})
  required_options[:auth] = true
  required_options[:container_key] = container_key
  perform(:post, 'edit_terminal', required_options)
end

#edit_terminal_access(container_key, access_rules = [], is_public_list = []) ⇒ Object

Edit the list of users and emails

Parameters:

  • container_key (String)

    the id of the terminal you are trying to edit

  • access_rules (defaults to: [])

    array of user to port mapping

  • is_public_list (defaults to: [])

    an array of ports open to the public

  • Hash (Hash)

    containing the :status "success" or "fail"

See Also:

Authentication:

  • Requires user_token and access_token



144
145
146
147
148
149
150
151
# File 'lib/terminal/modules/create_and_manage_terminals.rb', line 144

def edit_terminal_access(container_key, access_rules = [], is_public_list =[])
  options = {}
  options[:auth] = true
  options[:container_key] = container_key
  options[:access_rules] = access_rules
  options[:is_public_list] = is_public_list
  perform(:post, 'edit_terminal_access', options)
end

#get_terminal(container_key = nil, subdomain = nil) ⇒ Hash

Returns info about a specific terminal

Parameters:

  • container_key (String) (defaults to: nil)

    the id/key of the container and is optional

  • subdomain (String) (defaults to: nil)

    the sub domain of the terminal and is optional

Returns:

  • (Hash)

    represents one terminal, the hash is its attributes

See Also:

Authentication:

  • Requires user_token and access_token



27
28
29
30
31
32
33
# File 'lib/terminal/modules/create_and_manage_terminals.rb', line 27

def get_terminal(container_key = nil, subdomain = nil)
  options = {}
  options[:auth] = true
  options[:container_key] = container_key unless container_key.nil?
  options[:subdomain] = subdomain unless subdomain.nil?
  perform(:post, 'get_terminal', options)
end

#list_terminal_access(container_key) ⇒ Hash

List users and emails with view or edit access to one of your Terminal instances.

Parameters:

  • container_key (String)

    the id of the terminal you are trying to list

Returns:

  • (Hash)

    Hash containing the :is_public_list (ports open) and :access_rules, an array of user access

See Also:

Authentication:

  • Requires user_token and access_token



129
130
131
132
133
134
# File 'lib/terminal/modules/create_and_manage_terminals.rb', line 129

def list_terminal_access(container_key)
  options = {}
  options[:auth] = true
  options[:container_key] = container_key
  perform(:post, 'list_terminal_access', options)
end

#list_terminalsHash

Returns a list of all your terminals

Returns:

  • (Hash)

    of terminals, the key :terminals is top level

See Also:

Authentication:

  • Requires user_token and access_token



14
15
16
17
18
# File 'lib/terminal/modules/create_and_manage_terminals.rb', line 14

def list_terminals
  options = {}
  options[:auth] = true
  perform(:post, 'list_terminals', options )
end

#pause_terminal(container_key) ⇒ Hash

Pause a terminal instance

Parameters:

  • container_key (String)

    the key of the terminal you are trying to pause

Returns:

  • (Hash)

    represents the request_id that was made on the API

See Also:

Authentication:

  • Requires user_token and access_token



86
87
88
89
90
91
# File 'lib/terminal/modules/create_and_manage_terminals.rb', line 86

def pause_terminal(container_key)
  options = {}
  options[:auth] = true
  options[:container_key] = container_key
  perform(:post, 'pause_terminal', options)
end

#restart_terminal(container_key) ⇒ Hash

Restart a terminal instance

Parameters:

  • container_key (String)

    the key of the terminal you are trying to restart

Returns:

  • (Hash)

    represents the request_id that was made on the API

See Also:

Authentication:

  • Requires user_token and access_token



73
74
75
76
77
78
# File 'lib/terminal/modules/create_and_manage_terminals.rb', line 73

def restart_terminal(container_key)
  options = {}
  options[:auth] = true
  options[:container_key] = container_key
  perform(:post, 'restart_terminal', options)
end

#resume_terminal(container_key) ⇒ Hash

Resume a terminal instance

Parameters:

  • container_key (String)

    the key of the terminal you are trying to resume

Returns:

  • (Hash)

    represents the request_id that was made on the API

See Also:

Authentication:

  • Requires user_token and access_token



99
100
101
102
103
104
# File 'lib/terminal/modules/create_and_manage_terminals.rb', line 99

def resume_terminal(container_key)
  options = {}
  options[:auth] = true
  options[:container_key] = container_key
  perform(:post, 'resume_terminal', options)
end

#start_snapshot(snapshot_id, options = {}) ⇒ Hash

Start a terminal instance based on a snapshot

Parameters:

  • snapshot_id (String)

    the id of the snapshot you are trying to start

  • options (Hash) (defaults to: {})

    options to add to the request

Options Hash (options):

  • cpu (String)

    Example: "2 (max)" unclear if this is even honored by Terminal.com api

  • ram (String)
  • temporary (Boolean)
  • name (String)
  • autopause (Boolean)
  • startup_script (String)

Returns:

  • (Hash)

    represents the request_id you just made (to check its status is another call)

See Also:

Authentication:

  • Requires user_token and access_token



48
49
50
51
52
# File 'lib/terminal/modules/create_and_manage_terminals.rb', line 48

def start_snapshot(snapshot_id, options = {})
  options[:auth] = true
  options[:snapshot_id] = snapshot_id
  perform(:post, 'start_snapshot', options)
end