# -*- coding: utf-8 -*- require "magellan/cli/resources" module Magellan module Cli module Resources class ClientVersion < Base self.resource_key = "client_version" self.resource_dependency = {"project" => "project"} self.hidden_fields = %w[project_id created_at updated_at].map(&:freeze).freeze self.field_associations = { "stage_title_id" => {name: "stage", class: "Stage"}, } desc "create VERSION", "Create a new #{resource_name}" def create(version) stage = load_selection!(Stage) params = { parameter_name => { "stage_title_id" => stage["id"], "version" => version, } } post_json("/admin/#{resource_key}/new.json", params) # TODO implement select method # select(version) end desc "delete VERSION", "Delete the #{resource_name} specified by VERSION" def delete(version) q = build_query("version" => version).update(default_query) r = get_first_result!(self.class.resource_name, "/admin/#{resource_key}.json", q) super("/admin/#{resource_key}/#{r['id']}/delete") log_success("OK") end end end end end