# -*- coding: utf-8 -*- require "magellan/cli/resources" module Magellan module Cli module Resources class Project < Base self.resource_key = "project" self.resource_dependency = nil self.hidden_fields = %w[default_nebula_id created_at updated_at].map(&:freeze).freeze self.field_associations = {"organization_id" => {name: "organization", class: "Organization"} } desc "update ATTRIBUTES", "Update the ATTRIBUTES of the selected #{resource_name}" def update(attrs) s = load_selection!("project") attrs = JSON.parse(File.readable?(attrs) ? File.read(attrs) : attrs) put_json("/admin/project/#{s['id']}/edit", {"project" => attrs}) end desc "create NAME", "Create a new #{resource_name} with NAME" def create(name) o = load_selection!(Organization.parameter_name) params = { parameter_name => { "organization_id" => o["id"], "name" => name, } } post_json("/admin/#{resource_key}/new.json", params) select(name) end end end end end