require 'terminal/utils' module Terminal module Modules module CreateAndManageSnapshots include Terminal::Utils # Returns a list of all your snapshots, filtered by options # # @see https://www.terminal.com/api/docs#list-snapshots # @authentication Requires user_token and access_token # @param options [Hash] options to filter results on # @option options username [String] filter by the username # @option options tag [String] filter by the tag # @option options featured [Boolean] is it featured # @option options title [String] the title of the snapshot # @option options page [Integer] WTF # @option options perPage [Integer] paginate results I think # @option options sortby [String] popularity or date # @return [Hash] of snapshots, the key :snapshots is top level def list_snapshots(options = {}) options[:auth] = true perform(:post, 'list_snapshots', options) end # Returns a count of all your snapshots, filtered by options # # @see https://www.terminal.com/api/docs#count-snapshots # @authentication Requires user_token and access_token # @param options [Hash] options to filter on # @option options username [String] filter by the owner's username # @option options tag [String] filter by a tag # @option options featured [Boolean] filter by featured status # @option options title [String] filter by the title of the snapshot # @return [Hash] count, the key :snapshots_count is top level def count_snapshots(options = {}) options[:auth] = true perform(:post, 'count_snapshots', options) end # Delete a snapshot by id # # @see https://www.terminal.com/api/docs#delete-snapshot # @authentication Requires user_token and access_token # @param snapshot_id [String] the id of the snapshot to delete # @return [Hash] def delete_snapshot(snapshot_id) options = {} options[:auth] = true options[:snapshot_id] = snapshot_id perform(:post, 'delete_snapshot', options) end # Edit the metadata of a snapshot owned by your account. # # @see https://www.terminal.com/api/docs#edit-snapshot # @authentication Require user_token and access token # @param snapshot_id [String] the id of the snapshot you want to edit # @param options [Hash] options you want to edit (snapshot meta data) # @option options body [String] # @option options title [String] # @option options readme [String] # @option options tags [Array] # @option options public [Boolean] def edit_snapshot(snapshot_id, options ={}) options[:auth] = true options[:snapshot_id] = snapshot_id perform(:post, 'edit_snapshot', options) end # Create a snapshot of a terminal instance, but it actually makes no sense # # @see https://www.terminal.com/api/docs#snapshot-terminal # @authentication Requires user_token and access_token # @param container_key [String] # @param snapshot_id [String] # @param options [Hash] # @option options body # @return [Hash] def snapshot_terminal(container_key, snapshot_id, options = {}) options[:auth] = true options[:container_key] = container_key options[:snapshot_id] = snapshot_id perform(:post, 'snapshot_terminal', options) end end end end