Sha256: 96c5583a646a7b981cd499238b750be5836415ae227539d61a58c1d42154697d

Contents?: true

Size: 1.27 KB

Versions: 14

Compression:

Stored size: 1.27 KB

Contents

# -*- coding: utf-8 -*-
require "magellan/cli/resources"

module Magellan
  module Cli
    module Resources

      class Project < Base
        include Deletable

        self.resource_key = "project"
        self.resource_dependency = { "organization" =>  Organization.parameter_name }
        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", I18n.t(:update, scope: [:resources, :common, :cmd], resource_name: resource_name)
        def update(attrs)
          s = load_selection!(self.class)
          attrs = JSON.parse(File.readable?(attrs) ? File.read(attrs) : attrs)
          put_json("/admin/project/#{s['id']}/edit.json", {"project" => attrs})
        end

        desc "create NAME", I18n.t(:create, scope: [:resources, :common, :cmd], resource_name: resource_name)
        def create(name)
          o = load_selection!(Organization)
          params = {
            parameter_name => {
              "organization_id" => o["id"],
              "name" => name,
            }
          }
          post_json("/admin/#{resource_key}/new.json", params)
          select(name)
        end
      end

    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
magellan-cli-0.10.0 lib/magellan/cli/resources/project.rb
magellan-cli-0.9.1 lib/magellan/cli/resources/project.rb
magellan-cli-0.9.0 lib/magellan/cli/resources/project.rb
magellan-cli-0.8.3 lib/magellan/cli/resources/project.rb
magellan-cli-0.8.2 lib/magellan/cli/resources/project.rb
magellan-cli-0.8.1 lib/magellan/cli/resources/project.rb
magellan-cli-0.8.0 lib/magellan/cli/resources/project.rb
magellan-cli-0.7.11 lib/magellan/cli/resources/project.rb
magellan-cli-0.7.10 lib/magellan/cli/resources/project.rb
magellan-cli-0.7.9 lib/magellan/cli/resources/project.rb
magellan-cli-0.7.8 lib/magellan/cli/resources/project.rb
magellan-cli-0.7.7 lib/magellan/cli/resources/project.rb
magellan-cli-0.7.6 lib/magellan/cli/resources/project.rb
magellan-cli-0.7.5 lib/magellan/cli/resources/project.rb