class Magellan::Cli::Resources::Worker
Public Instance Methods
create(name, image_name)
click to toggle source
# File lib/magellan/cli/resources/worker.rb, line 18 def create(name, image_name) s = load_selection!(Stage::VERSION_PARAMETER_NAME) attrs = if path = options[:attributes_yaml] YAML.load_file(path) else {} end params = { "functions_worker" => { "stage_version_id" => s["id"], "name" => name, "image_name" => image_name, }.update(attrs) } post_json("/admin/#{self.resource_key}/new.js", params) select(name) end
prepare_images()
click to toggle source
# File lib/magellan/cli/resources/worker.rb, line 57 def prepare_images s = load_selection!(Worker) id = s["id"] r = post_json("/admin/functions~worker/#{id}/simple_method_call.json", {method_name: "prepare_images"}) targets = r["result"].select{|i| i["instance_amount"] > 0 } if targets.length == 1 img = r["result"].first Image.new.select(img["name"]) end Image.new.show_list(r["result"]) end
update(attrs)
click to toggle source
# File lib/magellan/cli/resources/worker.rb, line 38 def update(attrs) if File.readable?(attrs) attrs = YAML.load_file(attrs) else attrs = JSON.parse(attrs) end w = load_selection!(self.class) self.class.hidden_fields.each do |f| attrs.delete(f) end self.class.field_associations.keys.each do |f| attrs.delete(f) end params = { parameter_name => attrs } put_json("/admin/#{resource_key}/#{w["id"]}/edit.js", params) if v = attrs[self.class.caption_attr] select(v) end end