lib/rancher/api/models/instance.rb in rancher-api-beta-0.8.0.pre.beta vs lib/rancher/api/models/instance.rb in rancher-api-beta-0.8.1

- old
+ new

@@ -1,76 +1,34 @@ # frozen_string_literal: true -require 'rancher/api/models/instance/action' - module Rancher module Api - # - # instance usually container - # class Instance - include ::Her::Model + include Her::Model include Helpers::Model + include Rancher::Api::Helpers::Instance + belongs_to :account belongs_to :host + has_one :account + has_many :credentials + has_many :instances + has_many :hosts + has_many :volumes + has_many :mounts + has_many :serviceevents + has_many :serviceexposemaps + has_many :services + has_many :ports + has_many :instancelinks + has_many :healthcheckinstancehostmaps + has_many :targetinstancelinks + has_many :instancelabels + has_many :servicelogs - def container? - type == 'container' - end - - # - # Actions: execute, logs, restart, setlabels, stop, update - # - - # - # Execute works like this: - # - send request with command (array of strings) - # - in response you get WebSocket URL and token - # - connect to container using WebSocket and send token as parameter - # - get response and exit websocket connection - # - - # HTTP/1.1 POST /v1/projects/1a5/containers/1i382/?action=execute - # Host: 188.166.70.58:8080 - # Accept: application/json - # Content-Type: application/json - # Content-Length: 112 - - # { - # "attachStdin": true, - # "attachStdout": true, - # "command": [ - # "rake", - # "db:create", - # "db:schema:load", - # "db:seed" - # ], - # "tty": true - # } - - def execute(command) - url = actions['execute'] - - data = { - 'attachStdin' => true, - 'attachStdout' => true, - 'command' => command, - 'tty' => true - } - - action = Action.post(url, data) - action.run! - end - - def logs(lines = 20) - url = actions['logs'] - data = { - 'follow' => false, - 'lines' => lines - } - - action = Action.post(url, data) - action.run! - end + attributes :accountId, :created, :data, :description, :externalId, + :id, :kind, :name, :removeTime, :removed, + :state, :uuid, :transitioning, :transitioningMessage, :transitioningProgress, + :hostId end end end