Module: Terminal
- Defined in:
- lib/terminal.com.rb,
lib/terminal.com/api.rb
Defined Under Namespace
Classes: API, NetworkError
Constant Summary collapse
- VERSION =
The gem version.
'1.0.1'
- API_VERSION =
The Terminal.com API version.
'v0.1'
- HEADERS =
The default headers for the requests.
{'Content-Type' => 'application/json'}
BROWSE SNAPSHOTS & USERS collapse
-
.count_public_snapshots(**options) ⇒ Hash
Get a count of public snapshots, optionally filtered.
-
.get_profile(username) ⇒ Hash
Get information on a user.
-
.get_snapshot(snapshot_id) ⇒ Hash
Get information on a snapshot.
-
.list_public_snapshots(**options) ⇒ Hash
Get a list of public snapshots, optionally filtered and/or paginated.
CREATE AND MANAGE TERMINALS collapse
-
.delete_terminal(user_token, access_token, container_key) ⇒ Hash
Delete a Terminal instance.
- .edit_terminal(user_token, access_token, container_key, **options) ⇒ Object
-
.get_terminal(user_token, access_token, **options) ⇒ Hash
Get info about a Terminal instance of yours.
-
.list_terminals(user_token, access_token) ⇒ Hash
Get a list of all Terminal instances owned by your account.
-
.pause_terminal(user_token, access_token, container_key) ⇒ Hash
Pause a Terminal instance.
-
.restart_terminal(user_token, access_token, container_key) ⇒ Hash
Reboot a Terminal instance.
-
.resume_terminal(user_token, access_token, container_key) ⇒ Hash
Continue running a Terminal instance.
-
.start_snapshot(user_token, access_token, snapshot_id, **options) ⇒ Hash
Start a Terminal instance based on a snapshot.
CREATE AND MANAGE SNAPSHOTS collapse
-
.count_snapshots(user_token, access_token, **options) ⇒ Hash
Get a count of snapshots owned by your account, optionally filtered by the owner’s username, a tag, or the snapshot’s featured status.
-
.delete_snapshot(user_token, access_token, snapshot_id) ⇒ Hash
Delete a snapshot from your account.
-
.edit_snapshot(user_token, access_token, snapshot_id, **options) ⇒ Hash
Edit the metadata of a snapshot owned by your account.
-
.list_snapshots(user_token, access_token, **options) ⇒ Hash
Get a list of snapshots owned by your account, optionally filtered by the owner’s username, a tag, or the snapshot’s featured status.
-
.snapshot_terminal(user_token, access_token, container_key, **options) ⇒ Hash
Create a snapshot of a Terminal instance.
MANAGE TERMINAL ACCESS collapse
-
.add_terminal_links(user_token, access_token, container_key, *links) ⇒ Hash
Add to the list of your other Terminals who have access to one of your Terminal instances.
-
.edit_terminal_access(user_token, access_token, container_key, **options) ⇒ Hash
Edit the list of users and emails who have access to one of your Terminal instances.
-
.list_terminal_access(user_token, access_token, container_key) ⇒ Hash
List users and emails with view or edit access to one of your Terminal instances.
-
.remove_terminal_links(user_token, access_token, container_key, *links) ⇒ Hash
Remove from the list of Terminals who have access to one of your Terminal instances.
MANAGE TERMINAL DNS & DOMAINS collapse
-
.add_cname_record(user_token, access_token, domain, subdomain, port) ⇒ Hash
Map a domain in your CNAME record pool to one of your Terminal instances, making it accessible via that domain.
-
.add_domain_to_pool(user_token, access_token, domain) ⇒ Hash
Add a domain or subdomain of Terminal.com to your CNAME record pool, making it available to be associated with one of your Terminal instances.
-
.get_cname_records(user_token, access_token) ⇒ Hash
Get a list of domains in your CNAME record pool.
-
.remove_cname_record(user_token, access_token, domain) ⇒ Hash
Remove a domain mapping to one of your Terminal instances.
-
.remove_domain_from_pool(user_token, access_token, domain) ⇒ Hash
Remove a domain or subdomain of Terminal.com from your CNAME record pool.
MANAGE TERMINAL IDLE SETTINGS collapse
-
.get_terminal_idle_settings(user_token, access_token, container_key) ⇒ Hash
Get the idle settings for your terminal.
-
.set_terminal_idle_settings(user_token, access_token, container_key, action, triggers) ⇒ Hash
Set the idle settings for your Terminal.
MANAGE USAGE & CREDITS collapse
-
.balance(user_token, access_token) ⇒ Hash
Get the current balance of your account.
-
.balance_added(user_token, access_token) ⇒ Hash
Get a history of credits added to your account balance.
-
.burn_estimates(user_token, access_token) ⇒ Hash
Get a summary of the charges to your account, based on each Terminal instance that you have provisioned.
-
.burn_history(user_token, access_token) ⇒ Hash
Get a history of charges to your account balance.
-
.burn_state(user_token, access_token) ⇒ Hash
Get a summary of current active charges being billed to your account.
-
.gift(user_token, access_token, email, cents) ⇒ Hash
Gift some of your credits to another user.
-
.instance_price(instance_type, status = 'running') ⇒ Hash
Get the hourly pricing for a Terminal instance of a given type.
-
.instance_types ⇒ Hash
Get a list of the types of Terminals that may be started, and the specifications for each type (CPU, RAM, and pricing).
-
.terminal_usage_history(user_token, access_token) ⇒ Hash
Get a history of your Terminal usage.
MANAGE SSH PUBLIC KEYS collapse
-
.add_authorized_key_to_ssh_proxy(user_token, access_token, name, publicKey) ⇒ Hash
Add an SSH public key to our SSH proxy.
-
.add_authorized_key_to_terminal(user_token, access_token, container_key, publicKey) ⇒ Hash
Add an SSH public key to a given Terminal’s root user.
-
.del_authorized_key_from_ssh_proxy(user_token, access_token, name, fingerprint) ⇒ Hash
Delete an SSH public key from our SSH proxy.
-
.get_authorized_keys_from_ssh_proxy(user_token, access_token) ⇒ Hash
List the SSH public key on our SSH proxy.
TERMINAL PASSWORDS collapse
-
.add_terminal_password(user_token, access_token, container_key, name, password, port) ⇒ Hash
Assign login/password to a Terminal/port combination.
-
.list_terminal_passwords(user_token, access_token, container_key) ⇒ Hash
List all the assigned Terminal logins and the ports they are assigned to.
-
.remove_terminal_password(user_token, access_token, container_key, name) ⇒ Hash
Remove given login/password from a Terminal.
OTHER collapse
-
.request_progress(request_id) ⇒ Hash
Get info and status of an API request.
-
.who_am_i(user_token, access_token) ⇒ Hash
Get information about yourself! If invalid access/user token provided, returns null (but not an error).
IMPLEMENTATION collapse
-
.call(path, data) ⇒ Object
Make the HTTP call, retrieve and parse the JSON response.
-
.convert_timestamps_to_time(hash) ⇒ Object
private
We are ignoring timestamps in arrays since there are none in the API.
- .curl_debug(path, json) ⇒ Object private
- .ensure_both_cpu_and_ram_are_provided(options) ⇒ Object private
- .ensure_options_present(options, *required_keys) ⇒ Object
- .ensure_options_validity(options, *valid_keys) ⇒ Object private
- .parse_json(json) ⇒ Object private
- .request ⇒ Object private
Class Method Details
.add_authorized_key_to_ssh_proxy(user_token, access_token, name, publicKey) ⇒ Hash
Add an SSH public key to our SSH proxy.
890 891 892 893 894 895 896 |
# File 'lib/terminal.com.rb', line 890 def self.(user_token, access_token, name, publicKey) call('/add_authorized_key_to_ssh_proxy', user_token: user_token, access_token: access_token, name: name, publicKey: publicKey) end |
.add_authorized_key_to_terminal(user_token, access_token, container_key, publicKey) ⇒ Hash
Add an SSH public key to a given Terminal’s root user.
871 872 873 874 875 876 877 |
# File 'lib/terminal.com.rb', line 871 def self.(user_token, access_token, container_key, publicKey) call('/add_authorized_key_to_terminal', user_token: user_token, access_token: access_token, container_key: container_key, publicKey: publicKey) end |
.add_cname_record(user_token, access_token, domain, subdomain, port) ⇒ Hash
Map a domain in your CNAME record pool to one of your Terminal instances, making it accessible via that domain.
621 622 623 624 625 626 627 628 |
# File 'lib/terminal.com.rb', line 621 def self.add_cname_record(user_token, access_token, domain, subdomain, port) call('/add_cname_record', user_token: user_token, access_token: access_token, domain: domain, subdomain: subdomain, port: port) end |
.add_domain_to_pool(user_token, access_token, domain) ⇒ Hash
Add a domain or subdomain of Terminal.com to your CNAME record pool, making it available to be associated with one of your Terminal instances.
583 584 585 586 |
# File 'lib/terminal.com.rb', line 583 def self.add_domain_to_pool(user_token, access_token, domain) call('/add_domain_to_pool', user_token: user_token, access_token: access_token, domain: domain) end |
.add_terminal_links(user_token, access_token, container_key, *links) ⇒ Hash
Add to the list of your other Terminals who have access to one of your Terminal instances.
Currently this feature doesn’t have GUI, so don’t be surprised if you haven’t come across it yet.
473 474 475 476 477 478 479 |
# File 'lib/terminal.com.rb', line 473 def self.add_terminal_links(user_token, access_token, container_key, *links) call('/add_terminal_links', user_token: user_token, access_token: access_token, container_key: container_key, links: links) end |
.add_terminal_password(user_token, access_token, container_key, name, password, port) ⇒ Hash
Assign login/password to a Terminal/port combination.
944 945 946 947 948 949 950 951 952 |
# File 'lib/terminal.com.rb', line 944 def self.add_terminal_password(user_token, access_token, container_key, name, password, port) call('/add_terminal_password', user_token: user_token, access_token: access_token, container_key: container_key, name: name, password: password, port: port) end |
.balance(user_token, access_token) ⇒ Hash
Get the current balance of your account.
768 769 770 |
# File 'lib/terminal.com.rb', line 768 def self.balance(user_token, access_token) call('/balance', user_token: user_token, access_token: access_token) end |
.balance_added(user_token, access_token) ⇒ Hash
Get a history of credits added to your account balance.
784 785 786 |
# File 'lib/terminal.com.rb', line 784 def self.balance_added(user_token, access_token) call('/balance_added', user_token: user_token, access_token: access_token) end |
.burn_estimates(user_token, access_token) ⇒ Hash
Get a summary of the charges to your account, based on each Terminal instance that you have provisioned. Note that inactive and paused terminals do not incur charges.
854 855 856 |
# File 'lib/terminal.com.rb', line 854 def self.burn_estimates(user_token, access_token) call('/burn_estimates', user_token: user_token, access_token: access_token) end |
.burn_history(user_token, access_token) ⇒ Hash
Get a history of charges to your account balance.
816 817 818 |
# File 'lib/terminal.com.rb', line 816 def self.burn_history(user_token, access_token) call('/burn_history', user_token: user_token, access_token: access_token) end |
.burn_state(user_token, access_token) ⇒ Hash
Get a summary of current active charges being billed to your account.
840 841 842 |
# File 'lib/terminal.com.rb', line 840 def self.burn_state(user_token, access_token) call('/burn_state', user_token: user_token, access_token: access_token) end |
.call(path, data) ⇒ Object
Make the HTTP call, retrieve and parse the JSON response. Rewrite this method if you wish to use a different HTTP library.
1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 |
# File 'lib/terminal.com.rb', line 1047 def self.call(path, data) path = "/#{API_VERSION}#{path}" json = data.to_json curl_debug(path, data.to_json) response = request.post(path, json, HEADERS) status = response.code.to_i return parse_json(response.body) if status == 200 raise "Unexpected status #{status}: #{response.inspect}" rescue SocketError => error raise NetworkError.new(error) end |
.convert_timestamps_to_time(hash) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
We are ignoring timestamps in arrays since there are none in the API. Also, JSON document doesn’t have to be an object, but in Terminal.com API, they all are. TODO: Test it.
1086 1087 1088 1089 1090 1091 1092 1093 1094 |
# File 'lib/terminal.com.rb', line 1086 def self.(hash) hash.each do |key, value| if value.is_a?(Hash) (value) elsif value.is_a?(String) && value.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+Z$/) hash[key] = Time.parse(value) end end end |
.count_public_snapshots(**options) ⇒ Hash
Get a count of public snapshots, optionally filtered.
94 95 96 97 98 99 |
# File 'lib/terminal.com.rb', line 94 def self.count_public_snapshots(**) (, :username, :tag, :featured, :title) call('/count_public_snapshots', ) end |
.count_snapshots(user_token, access_token, **options) ⇒ Hash
Get a count of snapshots owned by your account, optionally filtered by the owner’s username, a tag, or the snapshot’s featured status. You may use a combination of filters.
381 382 383 384 385 386 387 388 |
# File 'lib/terminal.com.rb', line 381 def self.count_snapshots(user_token, access_token, **) (, :username, :tag, :featured, :title) .merge!(user_token: user_token, access_token: access_token) call('/count_snapshots', ) end |
.curl_debug(path, json) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 |
# File 'lib/terminal.com.rb', line 1064 def self.curl_debug(path, json) return if ENV['DBG'].nil? headers = HEADERS.reduce(Array.new) do |buffer, (key, value)| buffer << "#{key}: #{value}" end.join(' ') STDERR.puts <<-EOF curl -L -X POST -H '#{headers}' -d '#{json}' https://api.terminal.com#{path} EOF end |
.del_authorized_key_from_ssh_proxy(user_token, access_token, name, fingerprint) ⇒ Hash
Delete an SSH public key from our SSH proxy.
909 910 911 912 913 914 915 |
# File 'lib/terminal.com.rb', line 909 def self.(user_token, access_token, name, fingerprint) call('/del_authorized_key_from_ssh_proxy', user_token: user_token, access_token: access_token, name: name, fingerprint: fingerprint) end |
.delete_snapshot(user_token, access_token, snapshot_id) ⇒ Hash
Delete a snapshot from your account. This cannot be undone.
399 400 401 402 403 404 |
# File 'lib/terminal.com.rb', line 399 def self.delete_snapshot(user_token, access_token, snapshot_id) call('/delete_snapshot', user_token: user_token, access_token: access_token, snapshot_id: snapshot_id) end |
.delete_terminal(user_token, access_token, container_key) ⇒ Hash
Delete a Terminal instance.
241 242 243 244 |
# File 'lib/terminal.com.rb', line 241 def self.delete_terminal(user_token, access_token, container_key) call('/delete_terminal', user_token: user_token, access_token: access_token, container_key: container_key) end |
.edit_snapshot(user_token, access_token, snapshot_id, **options) ⇒ Hash
Edit the metadata of a snapshot owned by your account.
422 423 424 425 426 427 428 429 |
# File 'lib/terminal.com.rb', line 422 def self.edit_snapshot(user_token, access_token, snapshot_id, **) (, :body, :title, :readme, :tags, :public, :custom_data) .merge!(user_token: user_token, access_token: access_token, snapshot_id: snapshot_id) call('/edit_snapshot', ) end |
.edit_terminal(user_token, access_token, container_key, **options) ⇒ Object
315 316 317 318 319 320 321 322 323 324 325 |
# File 'lib/terminal.com.rb', line 315 def self.edit_terminal(user_token, access_token, container_key, **) ensure_both_cpu_and_ram_are_provided() (, :cpu, :ram, :diskspace) (, :cpu, :ram, :diskspace, :name) .merge!(user_token: user_token, access_token: access_token, container_key: container_key) call('/edit_terminal', ) end |
.edit_terminal_access(user_token, access_token, container_key, **options) ⇒ Hash
Edit the list of users and emails who have access to one of your Terminal instances.
540 541 542 543 544 545 546 |
# File 'lib/terminal.com.rb', line 540 def self.edit_terminal_access(user_token, access_token, container_key, **) (, :is_public_list, :access_rules) .merge!(user_token: user_token, access_token: access_token, container_key: container_key) call('/edit_terminal_access', ) end |
.ensure_both_cpu_and_ram_are_provided(options) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
1106 1107 1108 1109 1110 |
# File 'lib/terminal.com.rb', line 1106 def self.ensure_both_cpu_and_ram_are_provided() if ([:cpu] && ! [:ram]) || ([:ram] && ! [:cpu]) raise ArgumentError.new('You have to specify both cpu and ram of the corresponding instance type as described at https://www.terminal.com/faq#instanceTypes') end end |
.ensure_options_present(options, *required_keys) ⇒ Object
1112 1113 1114 1115 1116 1117 1118 |
# File 'lib/terminal.com.rb', line 1112 def self.(, *required_keys) required_keys.each do |key| unless .has_key?(key) raise ArgumentError.new("Option #{key} is required, but is missing.") end end end |
.ensure_options_validity(options, *valid_keys) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
1097 1098 1099 1100 1101 1102 1103 |
# File 'lib/terminal.com.rb', line 1097 def self.(, *valid_keys) = (.keys - valid_keys) unless .empty? raise ArgumentError.new("Unrecognised options: #{.inspect[1..-2]}") end end |
.get_authorized_keys_from_ssh_proxy(user_token, access_token) ⇒ Hash
List the SSH public key on our SSH proxy.
926 927 928 929 |
# File 'lib/terminal.com.rb', line 926 def self.(user_token, access_token) call('/get_authorized_keys_from_ssh_proxy', user_token: user_token, access_token: access_token) end |
.get_cname_records(user_token, access_token) ⇒ Hash
Get a list of domains in your CNAME record pool. Domains returned by this call can be associated to your Terminal instances.
566 567 568 569 |
# File 'lib/terminal.com.rb', line 566 def self.get_cname_records(user_token, access_token) call('/get_cname_records', user_token: user_token, access_token: access_token) end |
.get_profile(username) ⇒ Hash
Get information on a user.
70 71 72 |
# File 'lib/terminal.com.rb', line 70 def self.get_profile(username) call('/get_profile', username: username) end |
.get_snapshot(snapshot_id) ⇒ Hash
Get information on a snapshot.
54 55 56 |
# File 'lib/terminal.com.rb', line 54 def self.get_snapshot(snapshot_id) call('/get_snapshot', snapshot_id: snapshot_id) end |
.get_terminal(user_token, access_token, **options) ⇒ Hash
Get info about a Terminal instance of yours. You can specify either ‘container_key` or `subdomain`.
177 178 179 180 181 182 183 |
# File 'lib/terminal.com.rb', line 177 def self.get_terminal(user_token, access_token, **) (, :container_key, :subdomain) .merge!(user_token: user_token, access_token: access_token) call('/get_terminal', ) end |
.get_terminal_idle_settings(user_token, access_token, container_key) ⇒ Hash
Get the idle settings for your terminal.
703 704 705 706 707 708 |
# File 'lib/terminal.com.rb', line 703 def self.get_terminal_idle_settings(user_token, access_token, container_key) call('/get_terminal_idle_settings', user_token: user_token, access_token: access_token, container_key: container_key) end |
.gift(user_token, access_token, email, cents) ⇒ Hash
Gift some of your credits to another user. Denominated in whole integer US cents ($0.01). You may only gift credits if you have previously purchased credits.
800 801 802 803 804 805 806 |
# File 'lib/terminal.com.rb', line 800 def self.gift(user_token, access_token, email, cents) call('/gift', user_token: user_token, access_token: access_token, email: email, cents: cents) end |
.instance_price(instance_type, status = 'running') ⇒ Hash
Get the hourly pricing for a Terminal instance of a given type. If a instance is stopped, price will be zero.
752 753 754 |
# File 'lib/terminal.com.rb', line 752 def self.instance_price(instance_type, status = 'running') call('/instance_price', instance_type: instance_type, status: status) end |
.instance_types ⇒ Hash
Get a list of the types of Terminals that may be started, and the specifications for each type (CPU, RAM, and pricing).
733 734 735 |
# File 'lib/terminal.com.rb', line 733 def self.instance_types call('/instance_types', Hash.new) end |
.list_public_snapshots(**options) ⇒ Hash
Get a list of public snapshots, optionally filtered and/or paginated.
124 125 126 127 128 129 |
# File 'lib/terminal.com.rb', line 124 def self.list_public_snapshots(**) (, :username, :tag, :featured, :title, :page, :perPage, :sortby) call('/list_public_snapshots', ) end |
.list_snapshots(user_token, access_token, **options) ⇒ Hash
Get a list of snapshots owned by your account, optionally filtered by the owner’s username, a tag, or the snapshot’s featured status. You may use a combination of filters.
352 353 354 355 356 357 358 359 |
# File 'lib/terminal.com.rb', line 352 def self.list_snapshots(user_token, access_token, **) (, :username, :tag, :featured, :title, :page, :perPage) .merge!(user_token: user_token, access_token: access_token) call('/list_snapshots', ) end |
.list_terminal_access(user_token, access_token, container_key) ⇒ Hash
List users and emails with view or edit access to one of your Terminal instances.
514 515 516 517 518 519 |
# File 'lib/terminal.com.rb', line 514 def self.list_terminal_access(user_token, access_token, container_key) call('/list_terminal_access', user_token: user_token, access_token: access_token, container_key: container_key) end |
.list_terminal_passwords(user_token, access_token, container_key) ⇒ Hash
List all the assigned Terminal logins and the ports they are assigned to.
962 963 964 965 966 967 |
# File 'lib/terminal.com.rb', line 962 def self.list_terminal_passwords(user_token, access_token, container_key) call('/list_terminal_passwords', user_token: user_token, access_token: access_token, container_key: container_key) end |
.list_terminals(user_token, access_token) ⇒ Hash
Get a list of all Terminal instances owned by your account.
147 148 149 150 |
# File 'lib/terminal.com.rb', line 147 def self.list_terminals(user_token, access_token) call('/list_terminals', user_token: user_token, access_token: access_token) end |
.parse_json(json) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
1077 1078 1079 |
# File 'lib/terminal.com.rb', line 1077 def self.parse_json(json) (JSON.parse(json)) end |
.pause_terminal(user_token, access_token, container_key) ⇒ Hash
Pause a Terminal instance. The instance will be offline and inaccessible, and you will not be charged as long as it remains paused.
269 270 271 272 |
# File 'lib/terminal.com.rb', line 269 def self.pause_terminal(user_token, access_token, container_key) call('/pause_terminal', user_token: user_token, access_token: access_token, container_key: container_key) end |
.remove_cname_record(user_token, access_token, domain) ⇒ Hash
Remove a domain mapping to one of your Terminal instances. This will mean you can no longer access the Terminal instance from that domain.
641 642 643 644 645 646 |
# File 'lib/terminal.com.rb', line 641 def self.remove_cname_record(user_token, access_token, domain) call('/remove_cname_record', user_token: user_token, access_token: access_token, domain: domain) end |
.remove_domain_from_pool(user_token, access_token, domain) ⇒ Hash
Remove a domain or subdomain of Terminal.com from your CNAME record pool.
598 599 600 601 |
# File 'lib/terminal.com.rb', line 598 def self.remove_domain_from_pool(user_token, access_token, domain) call('/remove_domain_from_pool', user_token: user_token, access_token: access_token, domain: domain) end |
.remove_terminal_links(user_token, access_token, container_key, *links) ⇒ Hash
Remove from the list of Terminals who have access to one of your Terminal instances.
490 491 492 493 494 495 496 |
# File 'lib/terminal.com.rb', line 490 def self.remove_terminal_links(user_token, access_token, container_key, *links) call('/remove_terminal_links', user_token: user_token, access_token: access_token, container_key: container_key, links: links) end |
.remove_terminal_password(user_token, access_token, container_key, name) ⇒ Hash
Remove given login/password from a Terminal.
978 979 980 981 982 983 984 |
# File 'lib/terminal.com.rb', line 978 def self.remove_terminal_password(user_token, access_token, container_key, name) call('/remove_terminal_password', user_token: user_token, access_token: access_token, container_key: container_key, name: name) end |
.request ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
1034 1035 1036 |
# File 'lib/terminal.com.rb', line 1034 def self.request @request ||= Net::HTTP.new('api.terminal.com') end |
.request_progress(request_id) ⇒ Hash
Get info and status of an API request.
1026 1027 1028 |
# File 'lib/terminal.com.rb', line 1026 def self.request_progress(request_id) call('/request_progress', request_id: request_id) end |
.restart_terminal(user_token, access_token, container_key) ⇒ Hash
Reboot a Terminal instance.
254 255 256 257 |
# File 'lib/terminal.com.rb', line 254 def self.restart_terminal(user_token, access_token, container_key) call('/restart_terminal', user_token: user_token, access_token: access_token, container_key: container_key) end |
.resume_terminal(user_token, access_token, container_key) ⇒ Hash
Continue running a Terminal instance. The Terminal will continue being charged, and will keep running so long as you maintain a positive balance in your account.
284 285 286 287 |
# File 'lib/terminal.com.rb', line 284 def self.resume_terminal(user_token, access_token, container_key) call('/resume_terminal', user_token: user_token, access_token: access_token, container_key: container_key) end |
.set_terminal_idle_settings(user_token, access_token, container_key, action, triggers) ⇒ Hash
Set the idle settings for your Terminal.
667 668 669 670 671 672 673 674 |
# File 'lib/terminal.com.rb', line 667 def self.set_terminal_idle_settings(user_token, access_token, container_key, action, triggers) call('/set_terminal_idle_settings', user_token: user_token, access_token: access_token, container_key: container_key, action: action, triggers: triggers) end |
.snapshot_terminal(user_token, access_token, container_key, **options) ⇒ Hash
Create a snapshot of a Terminal instance.
441 442 443 444 445 446 447 448 |
# File 'lib/terminal.com.rb', line 441 def self.snapshot_terminal(user_token, access_token, container_key, **) (, :body, :title, :readme, :tags, :public) .merge!(user_token: user_token, access_token: access_token, container_key: container_key) call('/snapshot_terminal', ) end |
.start_snapshot(user_token, access_token, snapshot_id, **options) ⇒ Hash
Start a Terminal instance based on a snapshot.
221 222 223 224 225 226 227 228 229 |
# File 'lib/terminal.com.rb', line 221 def self.start_snapshot(user_token, access_token, snapshot_id, **) ensure_both_cpu_and_ram_are_provided() (, :cpu, :ram, :temporary, :name, :autopause, :startup_script, :custom_data) .merge!(user_token: user_token, access_token: access_token, snapshot_id: snapshot_id) call('/start_snapshot', ) end |
.terminal_usage_history(user_token, access_token) ⇒ Hash
Get a history of your Terminal usage.
828 829 830 |
# File 'lib/terminal.com.rb', line 828 def self.terminal_usage_history(user_token, access_token) call('/terminal_usage_history', user_token: user_token, access_token: access_token) end |
.who_am_i(user_token, access_token) ⇒ Hash
Get information about yourself! If invalid access/user token provided, returns null (but not an error).
1014 1015 1016 |
# File 'lib/terminal.com.rb', line 1014 def self.who_am_i(user_token, access_token) call('/who_am_i', user_token: user_token, access_token: access_token) end |