require 'terminal/utils' module Terminal module Modules module CreateAndManageTerminals include Terminal::Utils # Returns a list of all your terminals # # @see https://www.terminal.com/api/docs#list-terminals # @authentication Requires user_token and access_token # @return [Hash] of terminals, the key :terminals is top level def list_terminals options = {} options[:auth] = true perform(:post, 'list_terminals', options ) end # Returns info about a specific terminal # # @see https://www.terminal.com/api/docs#get-terminal # @authentication Requires user_token and access_token # @param container_key [String] the id/key of the container and is optional # @param subdomain [String] the sub domain of the terminal and is optional # @return [Hash] represents one terminal, the hash is its attributes 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 # Start a terminal instance based on a snapshot # # @see https://www.terminal.com/api/docs#start-snapshot # @authentication Requires user_token and access_token # @param snapshot_id [String] the id of the snapshot you are trying to start # @param options [Hash] options to add to the request # @option options cpu [String] Example: "2 (max)" unclear if this is even honored by Terminal.com api # @option options ram [String] # @option options temporary [Boolean] # @option options name [String] # @option options autopause [Boolean] # @option options startup_script [String] # @return [Hash] represents the request_id you just made (to check its status is another call) def start_snapshot(snapshot_id, options = {}) options[:auth] = true options[:snapshot_id] = snapshot_id perform(:post, 'start_snapshot', options) end # Delete a terminal instance # # @see https://www.terminal.com/api/docs#delete-terminal # @authentication Requires user_token and access_token # @param container_key [String] the key of the terminal you are trying to delete # @return [Hash] represents the :status of the request and the :result def delete_terminal(container_key) options = {} options[:auth] = true options[:container_key] = container_key perform(:post, 'delete_terminal', options) end # Restart a terminal instance # # @see https://www.terminal.com/api/docs#restart-terminal # @authentication Requires user_token and access_token # @param container_key [String] the key of the terminal you are trying to restart # @return [Hash] represents the request_id that was made on the API def restart_terminal(container_key) options = {} options[:auth] = true options[:container_key] = container_key perform(:post, 'restart_terminal', options) end # Pause a terminal instance # # @see https://www.terminal.com/api/docs#pause-terminal # @authentication Requires user_token and access_token # @param container_key [String] the key of the terminal you are trying to pause # @return [Hash] represents the request_id that was made on the API def pause_terminal(container_key) options = {} options[:auth] = true options[:container_key] = container_key perform(:post, 'pause_terminal', options) end # Resume a terminal instance # # @see https://www.terminal.com/api/docs#resume-terminal # @authentication Requires user_token and access_token # @param container_key [String] the key of the terminal you are trying to resume # @return [Hash] represents the request_id that was made on the API def resume_terminal(container_key) options = {} options[:auth] = true options[:container_key] = container_key perform(:post, 'resume_terminal', options) end # Edit the resources and/or name of a Terminal instance # # @see https://www.terminal.com/api/docs#edit-terminal # @authentication Requires user_token and access_token # @param container_key [String] the id of the terminal you are trying to edit # @param required_options [Hash] hash of other required params cpu, ram, diskspace, name # @required_option cpu [String] cpu of the terminal to edit to # @required_option ram [String] ram to edit the terminal to # @required_option cpu [String] disk space to edit to # @required_option name [String] name to edit the terminal to # @return [Hash] Hash containing the :status and the :request_id for the request def edit_terminal(container_key, required_options ={}) required_options[:auth] = true requireed_options[:container_key] = container_key perform(:post, 'edit_terminal', required_options) end end end end